Skip to main content
September 25, 2022
Question

Map() function

  • September 25, 2022
  • 7 replies
  • 0 views

What is map function what it does and how we use it.

I see in some interfaces it has been used in ruleinputs as a datatype.

    7 replies

    Participating Frequently
    September 25, 2022

    Hi maps are used to store data values as a key-value concept for more please check this out https://docs.appian.com/suite/help/22.3/fnc_system_map.html

    September 25, 2022

    Please elaborate I have seen the doc but still not sure can you please give an example

    Participating Frequently
    September 25, 2022

    What are you not sure about? If you want to know how it is used check the below code.

    =a!localVariables(
      local!items: {
        a!map(item: "Item 1", qty: 1, unitPrice: 10),
        a!map(item: "Item 2", qty: 2, unitPrice: 20)
      },
      a!gridLayout(
        label: "Products",
        instructions: "Update the item name, quantity, or unit price.",
        headerCells: {
          a!gridLayoutHeaderCell(label: "Item"),
          a!gridLayoutHeaderCell(label: "Qty"),
          a!gridLayoutHeaderCell(label: "Unit Price"),
          a!gridLayoutHeaderCell(label: "Total", align: "RIGHT")
        },
        rows: {
          a!gridRowLayout(
            contents: {
              a!textField(
                value: local!items[1].item,
                saveInto: local!items[1].item
              ),
              a!integerField(
                value: local!items[1].qty,
                saveInto: local!items[1].qty
              ),
              a!floatingPointField(
                value: local!items[1].unitPrice,
                saveInto: local!items[1].unitPrice
              ),
              a!textField(
                value: dollar(tointeger(local!items[1].qty) * todecimal(local!items[1].unitPrice)),
                readOnly: true,
                align: "RIGHT"
              )
            }
          ),
          a!gridRowLayout(
            contents: {
              a!textField(
                value: local!items[2].item,
                saveInto: local!items[2].item
              ),
              a!integerField(
                value: local!items[2].qty,
                saveInto: local!items[2].qty
              ),
              a!floatingPointField(
                value: local!items[2].unitPrice,
                saveInto: local!items[2].unitPrice
              ),
              a!textField(
                value: dollar(tointeger(local!items[2].qty) * todecimal(local!items[2].unitPrice)),
                readOnly: true,
                align: "RIGHT"
              )
            }
          )
        },
        rowHeader: 1
      )
    )
    

    September 25, 2022

    The map is used to make your data as structured Data if CDT is not there for the same. It is like a key-value pair.

    davel001150
    September 26, 2022

    Basically the same thing as a dictionary, but with many other uses.  It's an ad hoc CDT-like thing that you define by filling it with whatever.  The cool thing is, unlike dictionary, you can pass it to a process model as a process variable and do lots of other things with it.  It's really cool for determining the structure the data will go into at runtime, but it does have some limits.

    September 26, 2022

    Thank you all