Save values in Item type

Former Member
Former Member
Hello I made 2 Item Type , the first one called (Input) , the second is Result . i made 4 input in the first one ( Input ) and i want to save the values in Result . Result contain fields : Id , date , name , comment i passed the value in server side , but i do know how can i save it in Result . my code : Innovator innovator = this.getInnovator(); var input = this.getProperty("string"); var input1 = this.getProperty("string1"); var input2 = this.getProperty("string2"); var input3 = this.getProperty("string3"); Item newResult = innovator.newItem("Result","add"); newResult.setProperty("id",input.ToString()); newResult.setProperty("date",input1.ToString()); newResult.setProperty("name",input2.ToString()); newResult.setProperty("comment",input3.ToString()); newResult = newResult.apply();  
  • I guess this line will make some trouble: newResult.setProperty(“id”,input.ToString()); Id is a system property, so you cannot overwrite it. If you want to link the Input-Item, use an additional property for storing the value: newResult.setProperty(“input_id”,input.ToString());
  • Former Member
    Former Member
    Thank you for your response . if I save only one value, there is no problem, for example Innovator innovator = this.getInnovator(); var input = this.getProperty(“string”); var input1 = this.getProperty(“string1”); var input2 = this.getProperty(“string2”); var input3 = this.getProperty(“string3”); Item newResult = innovator.newItem(“Result”,”add”); newResult.setProperty(“input_id”,input.ToString()); newResult = newResult.apply(input); but if I save id, date, name, comment does not work . the new code is : Innovator innovator = this.getInnovator(); var input = this.getProperty(“string”); var input1 = this.getProperty(“string1”); var input2 = this.getProperty(“string2”); var input3 = this.getProperty(“string3”); Item newResult = innovator.newItem(“Result”,”add”); newResult.setProperty(“id_input”,input.ToString()); newResult.setProperty(“date”,input1.ToString()); newResult.setProperty(“name”,input2.ToString()); newResult.setProperty(“comment”,input3.ToString()); newResult = newResult.apply(); return innovator.newResult(input1);
  • Without knowing the exact structure of your itemtypes, it´s hard to say whats missing. 1. Do you get any error message? 2. If not, add an error handler to the apply Method:
    newResult = newResult.apply();
    if (newResult .isError())
    {
        return inn.newError(newResult .getErrorDetail()); 
    } 
    3. One of your properties is called date. Is this one really a String property? 4. Are the field sizes equal? 5. Can Add / Permissions correct? 6. If you try the other properties indepentently, do they all work? 7. Where do you trigger this code and which event is used?
  • Former Member
    Former Member
    Hello , Thank you for your response . 1.i did not get Error , 2.properties is called dat and kind is date 5. i make the Permissions  correct if i save only 1 property there is no problem for example : Innovator innovator = this.getInnovator(); var input = this.getProperty(“string”); Item newResult = innovator.newItem(“Result”,”add”); newResult.setProperty(“input_id”,input.ToString()); newResult = newResult.apply(input); return innovator.newResult(input); With this code can i save input_id but if i add comment and date in name can i not
  • Former Member
    Former Member
    With this code can i save input_id but if i add date , comment and name can i not add the values .
  • I don´t know if this really is the problem, but you often use the var type and .ToString(). For this use case, there is no need to transform the data types.
    Innovator innovator = this.getInnovator();
    string input = this.getProperty("string");
    string input1 = this.getProperty("string1");
    ...
    
    Item newResult = innovator.newItem("Result","add");
    newResult.setProperty("id_input",input);
    newResult.setProperty("date",input1);
    ...
    
    newResult = newResult.apply();
    return innovator.newResult(input1);
  • Former Member
    Former Member
    thank you for your help . if i use the same value , there ist no problem for exmaple : Innovator innovator = this.getInnovator(); string input = this.getProperty("string"); string input1 = this.getProperty("string1"); Item newResult = innovator.newItem("Result","add");
    newResult.setProperty("id_input",input1); newResult.setProperty("date",input1); 
    newResult = newResult.apply(); return innovator.newResult(input1);