verifying if the records are same and incrementing the count

Certified Associate Developer

hi, 

I have a record list with values 

{name:"Test1",id:1},{name:"Test1",id:2},{name:"Test2",id:3},{name:"Test1",id:4}

my output should show - pid should be concat of the name and the sequence based on count

1. id:1,pid:"Test1001"

2. id:2,pid:"Test1002"

3.id:3,pid:"Test2001"

4.id:4,pid:"Test1003"

any code suggestion will help 

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    a!localVariables(
      local!data: {
        { name: "Test1", id: 1 },
        { name: "Test1", id: 2 },
        { name: "Test2", id: 3 },
        { name: "Test1", id: 1 }
      },
      a!forEach(
        local!data,
        a!map(
          id: property(fv!item, "id", null),
        pid: 
          concat(
          property(fv!item, "name", null),
          substitute(padleft(
            length(tointeger(wherecontains(
              tostring(property(fv!item, "name", null)),
              touniformstring(property(index(local!data,enumerate(fv!index)+1,{}),"name", null))
            ))),
            3)," ",0)
          )
        )
    )
    )

    This will return the data as per your requirement.

  • 0
    Certified Associate Developer
    in reply to Ranjith shanmugam

    thanks . I used your  idea in my test code 

    a!localVariables(
      local!data:rule!LMS_getRecords(),
     
      a!forEach(
        local!data,
        a!localVariables(
          local!length:
          length(tointeger(wherecontains(
            tostring(fv!item['recordType!{cc80e31a-494e-472f-ac5e-cf9fa9b84149}LMS SequenceTest.fields.{d68e1218-7f8d-474f-a34c-e40ba98630fd}name']),
            touniformstring(index(local!data['recordType!{cc80e31a-494e-472f-ac5e-cf9fa9b84149}LMS SequenceTest.fields.{d68e1218-7f8d-474f-a34c-e40ba98630fd}name'],enumerate(fv!index)+1,{}))
          ))
          ),
         
          a!update(data:'recordType!{cc80e31a-494e-472f-ac5e-cf9fa9b84149}LMS SequenceTest',index:fv!item['recordType!{cc80e31a-494e-472f-ac5e-cf9fa9b84149}LMS SequenceTest.fields.{4f1128ea-0f95-4ac9-9bcd-7bad52fe8bc5}refId'],value:local!length)
       
        )
         
      )  
      
      )

    record :  trying to insert the length  in the "refid column"

    getting an error in a!update , am I missing something in this function ? 

  • On line 14 for data parameter pass local!data and try

Reply Children