add PickerFieldUser value to rule input

Hi All,

can anyone please tel me how to add PickerFieldUsers value into rule input 

Thanks in advance

  Discussion posts and replies are publicly visible

Parents Reply Children
  • Hi Stewart, thanks for the reply , but the PickerFieldUsers field is inside Grid, so the Above one is not working
  • 0
    Certified Lead Developer
    in reply to vineethk0001
    If you have a more unusual use case, please provide relevant sample code so that we can see what you're trying to do.
  • Hi Mike,
    below is my code, please let me know what do i have to change,
    oad(
    local!apprName,
    local!Managers: {},
    a!formLayout(
    label: "Adding, Editing or deleting additional manager",
    contents: {
    a!gridLayout(
    totalCount: count(
    local!Managers
    ),
    headerCells: {
    a!gridLayoutHeaderCell(
    label: "Name"
    ),
    a!gridLayoutHeaderCell(
    label: "level"
    ),
    a!gridLayoutHeaderCell(
    label: ""
    )
    },
    rows: a!forEach(
    items: local!Managers,
    expression: a!gridRowLayout(
    id: fv!index,
    contents: {
    a!pickerFieldUsers(
    label: "Name " & fv!index,
    value: fv!item.Approvers,
    maxSelections: 3,
    required: true

    ),
    /* For the Title Column*/
    a!integerField(
    label: "Level " & fv!index,
    value: fv!item.Levels,
    saveInto: a!save(ri!Levels, fv!item.Levels),
    required: true
    ),
    /* For the Removal Column*/
    a!imageField(
    label: "delete " & fv!index,
    images: a!documentImage(
    document: a!iconIndicator(
    "REMOVE"
    ),
    altText: "Remove Employee",
    caption: "Remove " & fv!item.Name & " " & fv!item.Levels,
    link: a!dynamicLink(
    value: fv!index,
    saveInto: {
    a!save(
    local!Managers,
    remove(
    local!Managers,
    save!value
    )
    )
    }
    )
    ),
    size: "ICON"
    )
    }
    )
    ),
    addRowlink: a!dynamicLink(
    label: "Add Manager",
    value: {
    Name: ""
    },
    saveInto: {
    a!save(
    local!Managers,
    append(
    local!Managers,
    save!value
    )
    )
    }
    )
    )
    },
    buttons: a!buttonLayout(
    primaryButtons: a!buttonWidgetSubmit(
    label: "Submit"
    )
    )
    )
    )
  • 0
    Certified Lead Developer
    in reply to vineethk0001

    Well, your user picker wasn't saving anything in the version you posted because it doesn't contain any SaveInto.  I've revised your form somewhat to where it saves everything locally.  If you still need it to interact with a rule input in some specific way, you'll need to explain a bit more clearly what you're hoping to have happen.  But for now hopefully this is a good start:

    load(
      /*local!apprName,*/
      local!Managers: {},
      a!formLayout(
        label: "Adding, Editing or deleting additional manager",
        contents: {
          a!paragraphField(
            label: "DEBUG",
            showWhen: false(),
            value: local!Managers
          ),
          
          a!gridLayout(
            totalCount: count( local!Managers ),
            headerCells: {
              a!gridLayoutHeaderCell( label: "Name" ),
              a!gridLayoutHeaderCell( label: "level" ),
              a!gridLayoutHeaderCell( label: "" )
            },
            columnConfigs: {
              a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 5),
              a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 3),
              a!gridLayoutColumnConfig(width: "ICON")
            },
            rows: a!forEach(
              items: local!Managers,
              expression: a!gridRowLayout(
                id: fv!index,
                contents: {
                  a!pickerFieldUsers(
                    label: "Name " & fv!index,
                    value: fv!item.Approvers,
                    saveInto: fv!item.Approvers,
                    maxSelections: 3,
                    required: true
                  ),
                  /* For the Title Column*/
                  a!integerField(
                    label: "Level " & fv!index,
                    value: fv!item.Levels,
                    saveInto: {
                      /*a!save(*/
                        /*ri!Levels,*/
                        /*fv!item.Levels*/
                      /*),*/
                      fv!item.Levels
                    },
                    required: true
                  ),
                  /* For the Removal Column*/
                  a!richTextDisplayField(
                    value: {
                      a!richTextIcon(
                        icon: "REMOVE",
                        size: "MEDIUM",
                        caption: "Remove",
                        color: "NEGATIVE",
                        link: a!dynamicLink(
                          saveInto: {
                            a!save(
                              local!Managers,
                              remove(
                                local!Managers,
                                fv!index
                              )
                            )
                          }
                        ),
                        linkStyle: "STANDALONE"
                      )
                    }
                  )
                  /*a!imageField(*/
                    /*label: "delete " & fv!index,*/
                    /*images: a!documentImage(*/
                      /*document: a!iconIndicator( "REMOVE" ),*/
                      /*altText: "Remove Employee",*/
                      /*caption: "Remove " & fv!item.Name & " " & fv!item.Levels,*/
                      /*link: a!dynamicLink(*/
                        /*value: fv!index,*/
                        /*saveInto: {*/
                          /*a!save(*/
                            /*local!Managers,*/
                            /*remove(*/
                              /*local!Managers,*/
                              /*save!value*/
                            /*)*/
                          /*)*/
                        /*}*/
                      /*)*/
                    /*),*/
                    /*size: "ICON"*/
                  /*)*/
                }
              )
            ),
            addRowlink: a!dynamicLink(
              label: "Add Manager",
              /*value: {*/
                /*Approvers: {},*/
                /*Levels: null()*/
              /*},*/
              saveInto: {
                a!save(
                  local!Managers,
                  append(
                    local!Managers,
                    {
                      Approvers: {},
                      Levels: null()
                    }
                  )
                )
              }
            )
          )
        },
        buttons: a!buttonLayout(
          primaryButtons: a!buttonWidgetSubmit(
            label: "Submit"
          )
        )
      )
    )

  • Hi Mike,
    i tried the above , it worked, but when i hit on "Add New Manager" and key in the manager details, the array value gets replaced on the first row, how to over come this,
    what i have done is , i have used "JoinArray" property to take all the items and save in one with comma separated,
    not when i add the new approver, it should be added in the index 2 instead of replacing the first
  • 0
    Certified Lead Developer
    in reply to vineethk0001
    Can you explain a bit more about what you're trying to have happen, and what's happening incorrectly when you use my code posted above? When I click "Add Manager", it adds a new row which I assume is what you were expecting. Each row can have up to 4 users selected in the "name" column which also seems to be what you were after. I'm not sure where you're using joinArray() or what you're expecting it to do (but be aware that it creates a text-only output).
  • yes Mike, till that point its working, but when we create a new row clicking on "Add New manager" and key in the "Approvers" it will update in Rule Input Replacing the first Row data instead of appending it, something like,

    Approvers Level
    User1, User2 , User3 1 ->> in this point the Rule Input Array = User1;User2;User3(Index 1, 2, 3)
    User4, User5, User6 2 --> in this point the above data is over-rightten instead of adding a data into
    array Rule Input Array = User4;User5;User6(Index 1,2,3)

    so what i want is all the row data in the grid should be present in the Rule Input array
    something like

    rule Input array = {
    User1;User2;USer3,
    User4,User5;USer6,
    ...
    ....
    ....
    ....


    }
  • 0
    Certified Lead Developer
    in reply to vineethk0001
    what data type is the rule input?
  • 0
    Certified Lead Developer
    in reply to vineethk0001
    i believe you should be able to get it to work with array of text, where each member of the array is a concatenated list of usernames. however it might be best to be using an array of CDT where one of the fields of the CDT is an array of users - that way you wouldn't have to do as much special handling when saving / reading the rule input data.