Forum Discussion

Former_Member's avatar
Former_Member
Accelerator III
8 years ago

Making a new Item Type Mandatory

Hello All, So I have created 2 Lists (project_id & SystemLevel) and filled them with appropriate values. I have then added these to the list of properties in the Part Item Type. I then linked these to combo boxes and am happy with how they appear on the form. These two Lists are used to create a portion of a part number which they do. The problem is that I would like to make these combo boxes mandatory. When I select the required box and save, I get the following: Cannot insert the value NULL into column 'PROJECT_ID' etc. I'm guessing that the default value is blank when the Part form is loaded, which is not allowed. What I'm trying to achieve to ensure that this field is selected at the point of save, therefore its okay of field is blank when the form loads. How do you get round this? Cheers

7 Replies

  • Hello, Are you getting this error when you are saving the Part ItemType itself? If so, please check that any existing Part items have values set for their project_id and SystemLevel properties. Chris _________________________________ Christopher Gillis Aras Labs Software Engineer
  • Hi Chris, You're kind of right. and yes the message appears at the point of save. I checked and filled in the blanks of those parts that had previously been created, fortunately there were only about 6, and then tried to make the Project_ID field Required, but got the same error. Next I simply deleted all the parts I'd created and was then able to successfully flag Project_ID as Required. I then created 1 part ensuring that the SystemLevel field was filled. But I got the same message when trying to set the SystemLevel field as Required. This is the message in full:
    Cannot insert the value NULL into column 'SYSTEMLEVEL', table 'InnovatorSolutions.innovator.PART'; column does not allow nulls. UPDATE fails. The statement has been terminated. in SQL: ALTER TABLE [PART] ALTER COLUMN [SYSTEMLEVEL] NVARCHAR(180) NOT NULL
    Cheers
  • Hi there, Are there any more thoughts on this? I've tried to add a simple string field and make this mandatory only to get a similar message.:
    ALTER TABLE only allows columns to be added that can contain nulls, or have a DEFAULT definition specified, or the column being added is an identity or timestamp column, or alternatively if none of the previous conditions are satisfied the table must be empty to allow addition of this column. Column 'TEST' cannot be added to non-empty table 'PART' because it does not satisfy these conditions. in SQL: ALTER TABLE [PART] ADD [TEST] NVARCHAR(12) NOT NULL
    Does this mean that you cannot add and make mandatory any fields to the Part Item Type has been used to create Parts...?
  • Hello, I think the issue you are seeing is that, while the most recent generation of your parts may have a value for the SystemLevel property, there are older generations of those parts that do not. In order to save any new properties as Required, you will need to set some value for these older generations. One possible way of doing that would be use a Method like below which assigns some default value to all generations of an Item. Chris _____________________________________ Christopher Gillis Aras Labs Software Engineer
  • Thanks Chris for your suggestion. I understand your reasoning. I've pasted your code into a new Methods Item Type but then got some red crosses against lines 1, 4, 11 & 19 stating that Missing ";" before statement and then a whole bunch of errors against line 12. But I can't see anything wrong with it. Something else - When I tried to run the Program (as Client Side) I got a The method type (javascript) is not currently supported... Cheers  
  • Hello, This code was written to be run from a C# Server-side method. Does switching your Method to C# resolve the compilation errors you're seeing? Chris _____________________________ Christopher Gillis Aras Labs Software Engineer
  • Hi Chris, So a small detail then! Changed as you suggested and now get this error:
    Aras.Server.Core.ItemIsNotLockedException
    Cheers