Problem of saving updated grid field in database

Here is my code. I have one editable grid in which one priority field is there:

a!integerField(
label: "Priority",
labelPosition: "ABOVE",
value: if(not(isnull(fv!item.priority)),int(fv!item.priority)-rule!CRP_CheckPriority(fv!item.priority,fv!item.contentdomain),fv!item.priority),
/*saveInto: a!save(fv!item.priority,if(rule!CRP_CheckPriority(fv!item.priority,fv!item.contentdomain)>0,a!save(save!value,int(fv!item.priority)-rule!CRP_CheckPriority(fv!item.priority,fv!item.contentdomain)),save!value)), */
saveInto: {a!save(fv!item.priority,save!value)
/*if(rule!CRP_CheckPriority(fv!item.priority,fv!item.contentdomain)>0,a!save(fv!item.priority,int(fv!item.priority)-rule!CRP_CheckPriority(fv!item.priority,fv!item.contentdomain)),a!save(fv!item.priority,save!value))*/
},
refreshAfter: "UNFOCUS",
readOnly: if(local!gridreadonly="Edit",true,false),
validations: {if(and(local!gridreadonly="Save",not (isnull(fv!item.priority))),{if(count(rule!CRP_GetPriority(priority: fv!item.priority,contentdomain: fv!item.contentdomain,id:fv!item.id)) >0,"This Priority is already assigned to other Project..",null)},{}),
if(and(not (isnull(fv!item.priority)),int(fv!item.priority)>10),"Priority must be between 1 and 10","")}

),

Here one of the value of priority field of grid fv!item.priority  is 10 which is in database . when the grid is displayed it shows value 5 that is right as per my code in value line. But when i save the data it stores 10 not 5. but i want 5 to be stored in database. Tell me solution. what is the wrong in my code.

Please reply asap.

  Discussion posts and replies are publicly visible

Parents Reply Children
  •  local!items: { rule!CRP_Dashboard1(local!status{},local!contentdomain{},local!priority,local!businessunit1{}, if (and(not(isnull(local!modeler)),length(local!modeler)>0), user(usersearch({"firstName","lastName"},{1,1},split(local!modeler," ")[1], split(local!modeler," ")[2]),"username"), "" ), if (and(not(isnull(local!contentowner)),length(local!contentowner)>0), user(usersearch({"firstName","lastName"},{1,1},split(local!contentowner," ")[1], split(local!contentowner," ")[2]),"username"), "" ),if (and(not(isnull(local!createdby)),length(local!createdby)>0), user(usersearch({"firstName","lastName"},{1,1},split(local!createdby," ")[1], split(local!createdby," ")[2]),"username"), "" ),local!search,local!department,local!pathvalue).data},
      local!dataUpdated: a!forEach(
        items: local!items,
        expression: a!map(
          id: fv!item.id,
          fteSaving: fv!item.fteSaving,
          status:fv!item.status,
          contentdomain:fv!item.contentdomain,
          priority:if(not(isnull(fv!item.priority)),int(fv!item.priority)-rule!CRP_CheckPriority(fv!item.priority,fv!item.contentdomain),fv!item.priority),
          dateofCompletion:fv!item.dateofCompletion,
          percentageCompleted:fv!item.percentageCompleted,
          comment:fv!item.comment
        )
      ),
      
      a!gridLayout(
            label: "Project List",
            labelPosition: "ABOVE",
            headerCells: {
              a!gridLayoutHeaderCell(label: "Reference ID"),
              a!gridLayoutHeaderCell(label: "Project Name"),
              a!gridLayoutHeaderCell(label: "FTE Savings"),
              a!gridLayoutHeaderCell(label: "Project Status"),
              a!gridLayoutHeaderCell(label: "Content Domain"),
              /*a!gridLayoutHeaderCell(label: "Robotics Owner"),*/
              a!gridLayoutHeaderCell(label: "Priority"),
              a!gridLayoutHeaderCell(label: "Date Of Completion"),
              a!gridLayoutHeaderCell(label: "% Completed"),
              a!gridLayoutHeaderCell(label: "Comment")
              
            },
            columnConfigs: {},
            rows: a!forEach(
              items: local!dataUpdated,
              expression: a!gridRowLayout(
                contents: {
                  
                  a!textField(
                    label: "Reference ID",
                    labelPosition: "ABOVE",
                    value: rule!CRP_getReferenceIdForRequests(fv!item.id),
                    saveInto: {},
                    refreshAfter: "UNFOCUS",
                    readOnly: true,
                    validations: {}
                    
                  ),
                  /*a!textField(*/
                    /*label: "Project Name",*/
                    /*labelPosition: "ABOVE",*/
                    /*value: fv!item.projectName,*/
                    /*saveInto: {},*/
                    /*refreshAfter: "UNFOCUS",*/
                    /*readOnly: true,*/
                    /*validations: {}*/
    /*                */
                  /*),*/
                  a!linkField(
                    label:"Project Name",
                    links: {
                      a!recordLink(
                        label:fv!item.projectName,
                        recordType:'recordType!{953256b7-ada0-4458-9e7d-4827957f243d}Automation Project Inventory',
                        identifier: fv!item.id
                      )
                    }
                  ),
                 
                  a!textField(
                    label: "FTE Savings",
                    labelPosition: "ABOVE",
                    value: fv!item.fteSaving,
                    saveInto: {},
                    refreshAfter: "UNFOCUS",
                    readOnly: true,
                    validations: {}
                  ),
                  a!textField(
                    label: "Status",
                    labelPosition: "ABOVE",
                    value: rule!CRP_GetStatusbyid(fv!item.status),
                    saveInto: {},
                    refreshAfter: "UNFOCUS",
                    readOnly: true,
                    validations: {}
                  ),
                  a!textField(
                    label: "Content Domain",
                    labelPosition: "ABOVE",
                    value: rule!CRP_GetContentDomainbyid(fv!item.contentdomain),
                    saveInto: {},
                    refreshAfter: "UNFOCUS",
                    readOnly: true,
                    validations: {}
                  ),
                 
                  /*a!linkField(*/
                    /*label: "Robotics Owner",*/
                    /*labelPosition: "ABOVE",*/
                    /*links: {*/
                      /*a!userRecordLink(*/
                        /*label: rule!CRP_FormatName(fv!item.roboticsOwner),*/
                        /*user: fv!item.roboticsOwner*/
                      /*)*/
                    /*}*/
                    /*,*/
                    /*readOnly: true*/
                  /*),*/
                  a!integerField(
                    label: "Priority",
                    labelPosition: "ABOVE",
                    value: fv!item.priority,
                    saveInto: {a!save(fv!item.priority,save!value)
                    
                    
                    },
                    refreshAfter: "UNFOCUS",
                    readOnly: if(local!gridreadonly="Edit",true,false),
                    validations: {if(and(local!gridreadonly="Save",not (isnull(fv!item.priority))),{if(count(rule!CRP_GetPriority(priority: fv!item.priority,contentdomain: fv!item.contentdomain,id:fv!item.id)) >0,"This Priority is already assigned to other Project..",null)},{}),
                    if(and(not (isnull(fv!item.priority)),int(fv!item.priority)>10),"Priority must be between 1 and 10","")}
                    
                  ),
                  a!dateField(
                    label: "Date Of Completion",
                    labelPosition: "ABOVE",
                    value: fv!item.dateofCompletion,
                    saveInto: a!save(fv!item.dateofCompletion,save!value),                
                    refreshAfter: "UNFOCUS",
                    readOnly: if(local!gridreadonly="Edit",true,false)
                    
    
                  ),
                  a!integerField(
                    label: "% Completed",
                    labelPosition: "ABOVE",
                    value: fv!item.percentageCompleted,
                    saveInto: a!save(fv!item.percentageCompleted,save!value),                
                    refreshAfter: "UNFOCUS",
                    readOnly: if(local!gridreadonly="Edit",true,false)
                    
    
                  ),
                  a!textField(
                    label: "Comment",
                    labelPosition: "ABOVE",
                    value: fv!item.comment,
                    saveInto: a!save(fv!item.comment,save!value),                
                    
                    readOnly: if(local!gridreadonly="Edit",true,false)
                    
    
                  )
                }
              )
            )
          )

  • here local!items are like local!data in your code and then i define local!dataUpdated as you said and then in gridlayout see priority field . i want priority new value should be saved .

  • Ok this looks ok to me - how are you then saving the data to the database? Do you have a button that on save transfers the values from local!dataUpdated to a rule input?

  • Thanks Peter it works and i got my solution. Thanks for Help.