Skip to main content
Inspiring
November 22, 2021
Solved

a!recordFilterList in Order fulfillment app

  • November 22, 2021
  • 10 replies
  • 11 views

Hi,

Can anyone please help me to understand the below code.

How is defaultOption:"Me" differ from currentUser(my account)

a!recordFilterList(
  name: "Assignee",
  defaultOption: "Me",
  options: {
    /* We modify the standard logic to account for the "LoggedIn User" user */
    a!forEach(
      items: append(cons!VOF_ALL_ANALYSTS, {"LoggedIn User", null}),
      expression: if(
        fv!isLast,
        a!recordFilterListOption(
          id: fv!index,
          name: "Unassigned",
          filter: a!queryFilter(
            field: 'recordType!{c5bfe4ef-1564-4630-a19f-cbdaa1880a48}HZN_JC_JobCosting_recordtype1.fields.{0293d097-e030-4431-9bcc-f5742790bb82}assignee',
            operator: "is null"
          )
        ),
        /* Here we configure a flexible option for the logged in user to filter orders they are assigned */
        a!recordFilterListOption(
          id: fv!index,
          name: if(
            fv!index = count(cons!VOF_ALL_ANALYSTS) + 1,
            "Me",
            fv!item
          ),
          filter: a!queryFilter(
            field: 'recordType!{c5bfe4ef-1564-4630-a19f-cbdaa1880a48}HZN_JC_JobCosting_recordtype1.fields.{0293d097-e030-4431-9bcc-f5742790bb82}assignee',
            operator: "=",
            value: fv!item
          )
        ),
      )
    )
  },
  allowMultipleSelections: true
)

    Best answer by stewart.burchell

    I suspect the issue is wiht this line:

    items: append(cons!VOF_ALL_ANALYSTS, {"LoggedIn User", null}),

    The intention appears to take the list of users in the cons!VOF_ALL_ANALYSTS and add to that list two additional items: the logged in user, and null. These are the values that are being used to apply a filter with, so the string "LoggedIn User" should actually be replaced with the function fn!loggedInUser() i.e.:

    items: append(cons!VOF_ALL_ANALYSTS, {fn!loggedInUser(), null}),

    10 replies

    stewart.burchell
    Employee
    November 22, 2021

    For future reference please use the "Insert Code" option when  posting - it makes it easier to read/copy/paste when people are trying to answer questions.

    stewart.burchell
    Employee
    November 22, 2021

    ...in direct response to your post: what specifically do you need help with understanding?

    Inspiring
    November 22, 2021

    thanks for suggesting "Insert code" option.

     

    items: append(cons!VOF_ALL_ANALYSTS, {"LoggedIn User", null}),
          expression: if(
            fv!isLast,
            a!recordFilterListOption(
              id: fv!index,
              name: "Unassigned",
              filter: a!queryFilter(
                field: 'recordType!{c5bfe4ef-1564-4630-a19f-cbdaa1880a48}HZN_JC_JobCosting_recordtype1.fields.{0293d097-e030-4431-9bcc-f5742790bb82}assignee',
                operator: "is null"
              )

    I would like to know what is happening here in the above code. With respect to id, name. 

    stewart.burchell
    Employee
    November 22, 2021

    The overall purpose of the rule is to generate a list of values that will appear in a Record List 'User Filter' - that is, a filter that a User can select (in this case) one or more values to filter the list of Records by. 

    Each item that will appear in the generated drop-down is of type 'a!recordFilterListOption', and the help for this type tells you what each attribute for that type is:

    If you put your cursor inside the opening bracket for this function then you will see the above help appear in the bottom left of the expression editor: