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

      

    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))&tostring(property(fv!item,"id",null). ---> this returns length zero   
    touniformstring(property(index(local!data,enumerate(fv!index)+1,{}),"name", null))
    ))),
    3)," ",0)
    )
    )
    )
    )

Reply
  • 0
    Certified Associate Developer
    in reply to Ranjith shanmugam

      

    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))&tostring(property(fv!item,"id",null). ---> this returns length zero   
    touniformstring(property(index(local!data,enumerate(fv!index)+1,{}),"name", null))
    ))),
    3)," ",0)
    )
    )
    )
    )

Children