How to take specific field value from grid?

Certified Associate Developer

Hello All,

I have a requirement to fetch specific column data from grid and pass it to startProcess() function. Below is the scenario

Suppose my grid has below data

Field1                  Field2           Field3

Task1                  abc               pqr

Task2                  lmn               stu

Task3                  xyz                mnp

 

This data is coming from report and I set the identifier as TaskID. Now suppose if i select row two then the TaskID will be passed to the process model(Its basically to reassign the task) which is absolutely fine but I have a requirement to send an email notification to the user to whom the task is assigned and inside that email notification, I need to include the "Field2" value which is nothing but a task name. Can someone tell me how can I send the respected TaskName with TaskId to the process model? i.e if I select row 2 then I need to send TaskID and TaskName which is "lmn"

  Discussion posts and replies are publicly visible

Parents
  • Hello Vivek,

    You can play with the following code:

    load(
      local!animal_cdts: {
        {id: 1,description: "snake"},
        {id: 2,description: "lion"},
        {id: 3,description: "dog"},
        {id: 4,description: "cat"},
        {id: 5,description: "tiger"},
        {id: 6,description: "pig"}
      },
      local!selectedAnimal_int: null,
      local!selectedAnimal_cdt: null,
      local!animal_pagingInfo: a!gridSelection(
        pagingInfo: a!pagingInfo(
          startIndex: 1,
          batchSize: 5,
          sort: a!sortInfo(
            field: "id",
            ascending: true
          )
        ),
        selected: null
      ),
      with(
        local!animal_datasubset: todatasubset(
          local!animal_cdts,
          local!animal_pagingInfo.pagingInfo
        ),
        local!animalCurrentPage_cdts: local!animal_datasubset.data,
        a!formLayout(
          contents: {
            a!textField(
              label: "TEST - SELECTED ANIMAL",
              value: local!selectedAnimal_int,
              readOnly: true
            ),
            a!textField(
              label: "TEST - SELECTED ANIMAL OBEJCT",
              value: local!selectedAnimal_cdt,
              readOnly: true
            ),
            a!gridField(
              totalCount: local!animal_datasubset.totalCount,
              selection: true,
              identifiers: property(local!animalCurrentPage_cdts,"id",null),
              columns: {
                a!gridTextColumn(
                  label: "id",
                  field: "id",
                  data: property(local!animalCurrentPage_cdts,"id",null)
                ),
                a!gridTextColumn(
                  label: "description",
                  field: "description",
                  data: property(local!animalCurrentPage_cdts,"description",null)
                )
              },
              validations: if(
                count(local!animal_pagingInfo.selected) > 1,
                "You may only select one animal",
                null
              ),
              value: local!animal_pagingInfo,
              saveInto: {
                local!animal_pagingInfo,
                if(
                  count(local!animal_pagingInfo.selected) > 1,
                  {},
                  {
                    a!save(
                      target: local!selectedAnimal_int,
                      value: save!value.selected
                    ),
                    a!save(
                      target: local!selectedAnimal_cdt,
                      value: index(
                        local!animalCurrentPage_cdts,
                        wherecontains(
                          tointeger(local!selectedAnimal_int),
                          tointeger(property(local!animalCurrentPage_cdts,"id",null))
                        ),
                        null
                      )
                    )
                  }
                )
              }
            )
          }
        )
      )
    )

    On the above code, you will find the following:

    • a selected animal id 
    • a selected animal CDT.

    You can prepare your process model to receive one of the above options.

    I will recommend sending only the Id.

    Inside of your process model adds a new node to retrieve the rest of the information using a script task.  in this way, we are going to save some time processing the data.

    Regards.

Reply
  • Hello Vivek,

    You can play with the following code:

    load(
      local!animal_cdts: {
        {id: 1,description: "snake"},
        {id: 2,description: "lion"},
        {id: 3,description: "dog"},
        {id: 4,description: "cat"},
        {id: 5,description: "tiger"},
        {id: 6,description: "pig"}
      },
      local!selectedAnimal_int: null,
      local!selectedAnimal_cdt: null,
      local!animal_pagingInfo: a!gridSelection(
        pagingInfo: a!pagingInfo(
          startIndex: 1,
          batchSize: 5,
          sort: a!sortInfo(
            field: "id",
            ascending: true
          )
        ),
        selected: null
      ),
      with(
        local!animal_datasubset: todatasubset(
          local!animal_cdts,
          local!animal_pagingInfo.pagingInfo
        ),
        local!animalCurrentPage_cdts: local!animal_datasubset.data,
        a!formLayout(
          contents: {
            a!textField(
              label: "TEST - SELECTED ANIMAL",
              value: local!selectedAnimal_int,
              readOnly: true
            ),
            a!textField(
              label: "TEST - SELECTED ANIMAL OBEJCT",
              value: local!selectedAnimal_cdt,
              readOnly: true
            ),
            a!gridField(
              totalCount: local!animal_datasubset.totalCount,
              selection: true,
              identifiers: property(local!animalCurrentPage_cdts,"id",null),
              columns: {
                a!gridTextColumn(
                  label: "id",
                  field: "id",
                  data: property(local!animalCurrentPage_cdts,"id",null)
                ),
                a!gridTextColumn(
                  label: "description",
                  field: "description",
                  data: property(local!animalCurrentPage_cdts,"description",null)
                )
              },
              validations: if(
                count(local!animal_pagingInfo.selected) > 1,
                "You may only select one animal",
                null
              ),
              value: local!animal_pagingInfo,
              saveInto: {
                local!animal_pagingInfo,
                if(
                  count(local!animal_pagingInfo.selected) > 1,
                  {},
                  {
                    a!save(
                      target: local!selectedAnimal_int,
                      value: save!value.selected
                    ),
                    a!save(
                      target: local!selectedAnimal_cdt,
                      value: index(
                        local!animalCurrentPage_cdts,
                        wherecontains(
                          tointeger(local!selectedAnimal_int),
                          tointeger(property(local!animalCurrentPage_cdts,"id",null))
                        ),
                        null
                      )
                    )
                  }
                )
              }
            )
          }
        )
      )
    )

    On the above code, you will find the following:

    • a selected animal id 
    • a selected animal CDT.

    You can prepare your process model to receive one of the above options.

    I will recommend sending only the Id.

    Inside of your process model adds a new node to retrieve the rest of the information using a script task.  in this way, we are going to save some time processing the data.

    Regards.

Children
No Data