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

  • Hi Vivek
    Attaching sample logic. Please go through it.
    with(
    local!items: {
    {
    id: 123,
    name: "Appian"
    },
    {
    id: 234,
    name: "MySql"
    },
    {
    id: 345,
    name: "Java"
    }
    },
    local!selectedItem: 123,
    local!itemPosition: wherecontains(
    tointeger(
    local!selectedItem
    ),
    tointeger(
    index(
    local!items,
    "id",
    null
    )
    )
    ),
    if(
    rule!APN_isEmpty(
    local!itemPosition
    ),
    null,
    index(
    local!items,
    local!itemPosition,
    null
    )
    )
    )
  • Hi,

    From what I understand of your issue – you’re having difficulty passing in data from a specific row to a startProcess rule call.

    a!startProcess takes in a dictionary of inputs as parameters.
    From the documentation – “processParameters (Dictionary): A dictionary containing the parameters for the process and their values.”

    You can pass in the data into your start process call like the following:

    a!startProcess(

    processParameters:{
    taskId:Task2, /*Field1 value*/
    taskName:lmn /*Field2 value*/
    },

    )

    Another option would to be querying on the report from the task ID from inside the process model.

    I hope this helps!

  • HI Vivek,

    You can achieve this by two ways:

    1) StartProcess takes parameters as dictionary so in your process model just add a new variableField2/TaskName and make it parameter type so whenever this process model start ,it can take the taskName as input parameter.Now pass the Field2 value when you call the StartProcess function like below:


    a!startProcess{

    processParameters :{
    Field1:"value",
    Field2/taskName:"Field2 value"

    }

    2) In your process model, query the database to get Field2 value based on taskid and use it in your notification email.

    Regards
    Abhay
  • 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.