Using Rule Inputs Between Interfaces

No longer need assistance, thanks!

  Discussion posts and replies are publicly visible

  • The code sample you've posted makes it really unclear what your construct is or what you're expecting it to do.  For the a!gridColumn() snippet - where and how is that being called from the parent level, and what exactly are you expecting to actually happen by having the "sortField" and "value" being set to the Pokemon Choice rule input?  That doesn't really resemble how a!gridColumn() would usually work anyway, whether called as a sub-interface or not.

  • 0
    Certified Lead Developer

    As Mike mentioned what you say and what your code says is different. Are you able to provide full sale code which help us to provide some answer.

    you can also refer Appian documentation for some use case recipes here https://docs.appian.com/suite/help/23.1/SAIL_Recipes.htmlhttps://docs.appian.com/suite/help/23.1/SAIL_Recipes.html 

  • So for the grid column, I want it to display what's being selected in the dropdown in the other interface, purely read-only

  • Your link didn't work for me, and yes here's the full code

    a!localVariables(
      {
        a!gridField(
          data: a!recordData(
            recordType: 'recordType!{ba350028-3b3e-4bca-babd-abe7e223a3e9}DS APR COPY',
            filters: {
              a!queryFilter(
                field: 'recordType!{ba350028-3b3e-4bca-babd-abe7e223a3e9}DS APR COPY.fields.{4cada3be-cfb9-4975-aabf-7a131211805c}requestId',
                operator: "=",
                value: ri!requestId,
                applyWhen: a!isNotNullOrEmpty(ri!requestId)
              ),
              a!queryFilter(
                field: 'recordType!{ba350028-3b3e-4bca-babd-abe7e223a3e9}DS APR COPY.fields.{cc19b7f0-3dc0-469a-b711-93b382ede170}isActive',
                operator: "=",
                value: true()
              )
            }
          ),
          columns: {
          
            a!gridColumn(
              label: "Quality Codes",
              sortField: ri!pkmnChoice,
              value: ri!pkmnChoice,
              align: "CENTER",
              width: "NARROW"
            ),
            a!gridColumn(
              label: "Quantity",
              value: fv!row['recordType!{ba350028-3b3e-4bca-babd-abe7e223a3e9}DS APR COPY.fields.{80bf64db-41ec-407a-83d7-4b0cc8a10c9d}quantity'],
              align: "CENTER",
              width: "NARROW"
            ),
            a!gridColumn(
              label: "UOM",
              value: rule!DS_QE_GetUnitOfMeasureDescriptionFromId(
                fv!row['recordType!{ba350028-3b3e-4bca-babd-abe7e223a3e9}DS APR COPY.fields.{900f2942-bc71-4395-a119-66131a478806}uomID']
              ),
              align: "CENTER",
              width: "NARROW"
            ),
            a!gridColumn(
              label: "Unit Cost",
              value: if(
                a!isNullOrEmpty(
                  fv!row['recordType!{ba350028-3b3e-4bca-babd-abe7e223a3e9}DS APR COPY.fields.{ae629137-5672-4a79-9a06-76e70d68b215}unitCost']
                ),
                dollar("0"),
                dollar(
                  fv!row['recordType!{ba350028-3b3e-4bca-babd-abe7e223a3e9}DS APR COPY.fields.{ae629137-5672-4a79-9a06-76e70d68b215}unitCost']
                )
              ),
              align: "CENTER",
              width: "NARROW_PLUS"
            ),
    
          },
          borderStyle: "LIGHT",
          shadeAlternateRows: true(),
          refreshAlways: true(),
          showSearchBox: false(),
          showRefreshButton: false(),
          showExportButton: false()
        ),
        a!richTextDisplayField(
          label: "Total Cost: ",
          labelPosition: "COLLAPSED",
          value: a!richTextItem(
            text: "Total Cost:   " & dollar(a!defaultValue(ri!totalCost, 0)), style: "STRONG"),
          align: "RIGHT"
          
          
        )
      }
    )

    a!localVariables(
      local!numberOfExistingItems: a!refreshVariable(
        value: if(a!isNullOrEmpty(ri!requestItems), 0, length(ri!requestItems)),
        refreshOnReferencedVarChange: false()
      ),
      local!uomId: rule!APR_QE_GetUnitOfMeasure(),
      local!hardwareTypeList: rule!APR_QR_GetHardwareTypeList(),
      {
        a!gridLayout(
          label: "Material Request Items",
          labelPosition: "COLLAPSED",
          headerCells: {
            a!gridLayoutHeaderCell(
              label: "Item Part Number",
              helpTooltip: "Number to be traced in inventory.",
              align: "CENTER"
            ),
            a!gridLayoutHeaderCell(
              label: "Item Description",
              align: "CENTER"
            ),
            a!gridLayoutHeaderCell(
              label: "Manufacturer/Vendor Part Number",
              align: "CENTER"
            ),
            a!gridLayoutHeaderCell(label: "HW Class", align: "CENTER"),
            a!gridLayoutHeaderCell(label: "Quality Codes", align: "CENTER"),
            a!gridLayoutHeaderCell(label: "Quantity", align: "CENTER"),
            a!gridLayoutHeaderCell(label: "UOM", align: "CENTER"),
            a!gridLayoutHeaderCell(label: "Unit Cost", align: "CENTER"),
            a!gridLayoutHeaderCell(label: "Note", align: "CENTER"),
            a!gridLayoutHeaderCell(label: "Total Cost", align: "LEFT"),
            a!gridLayoutHeaderCell(label: "")
          },
          columnConfigs: {
            /* Item Part Number */
            a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 2),
            /* Item Description */
            a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 3),
            /* Manufacturer/Vendor Part Number */
            a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 2),
            /*Hardware Class*/
            a!gridLayoutColumnConfig(width: "NARROW"),
            /*Quality Codes*/
            a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 1),
            /*Quantity*/
            a!gridLayoutColumnConfig(width: "NARROW"),
            /* UOM */
            a!gridLayoutColumnConfig(width: "NARROW"),
            /* Unit Cost */
            a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 1),
            /* Note */
            a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 2),
            /* Total Cost */
            a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 1),
            /* Delete button */
            a!gridLayoutColumnConfig(width: "ICON")
          },
          rows: a!forEach(
            items: ri!requestItems,
            expression: a!gridRowLayout(
              id: fv!index,
              contents: {
                a!textField(
                  value: fv!item.partNumber,
                  saveInto: { fv!item.partNumber },
                  characterLimit: 255,
                  showCharacterCount: false,
                  required: true(),
                  requiredMessage: "Part Number cannot be empty",
                  validationGroup: "Validate_Form"
                  
                ),
                a!textField(
                  value: fv!item.description,
                  saveInto: { fv!item.description },
                  characterLimit: 1000,
                  showCharacterCount: false
                  
                ),
                a!textField(
                  value: fv!item.vendorPartNumber,
                  saveInto: { fv!item.vendorPartNumber },
                  characterLimit: 255,
                  showCharacterCount: false
                  
                ),
                a!dropdownField(
                  placeholder: "HW Class",
                  choiceLabels: index(
                    local!hardwareTypeList,
                    'recordType!{ad3656f4-f6c6-4b61-a1d3-6bdaa55d447c}APR Hardware Type.fields.{3ed3a1fc-1387-4d04-a871-66422d11e684}name'
                  ),
                  choiceValues: index(
                    local!hardwareTypeList,
                    'recordType!{ad3656f4-f6c6-4b61-a1d3-6bdaa55d447c}APR Hardware Type.fields.{37ea6949-fb4c-4209-9ce5-33f3777647b3}hardwareTypeId'
                  ),
                  value: fv!item.hardwareTypeId,
                  saveInto: fv!item.hardwareTypeId
                  
                ),
                a!localVariables(
                  local!PokemonChoice: null,
                  a!multipleDropdownField(
                    label: "Quality Codes",
                    choiceLabels: {
                      "Kabuto",
                      "Kabutops",
                      "Aerodactyl",
                      "Snorlax",
                      "Articuno",
                      "Zapdos",
                      "Moltres",
                      "Dratini",
                      "Dragonair",
                      "Dragonite",
                      "Mewtwo",
                      "Mew",
                    },
                    choiceValues: {
                      "Kabuto",
                      "Kabutops",
                      "Aerodactyl",
                      "Snorlax",
                      "Articuno",
                      "Zapdos",
                      "Moltres",
                      "Dratini",
                      "Dragonair",
                      "Dragonite",
                      "Mewtwo",
                      "Mew",
                    },
                    value: local!PokemonChoice,
                    saveInto: local!PokemonChoice,
                    placeholder: "Select a Pokemon",
                    )
                    ),
                a!integerField(
                  value: a!defaultValue(value: fv!item.quantity, default: 0),
                  saveInto: {
                    fv!item.quantity,
                    a!save(
                      target: fv!item.totalCost,
                      value: rule!APR_UTIL_calculateItemTotalCost(fv!item)
                    )
                  }
                ),
                a!dropdownField(
                  placeholder: "UOM",
                  choiceLabels: index(local!uomId, "description", {}),
                  choiceValues: index(local!uomId, "measureId", {}),
                  value: fv!item.uomId,
                  saveInto: { fv!item.uomId }
                ),
                a!floatingPointField(
                  value: a!defaultValue(value: fv!item.unitCost, default: 0),
                  saveInto: {
                    fv!item.unitCost,
                    a!save(
                      target: fv!item.totalCost,
                      value: rule!APR_UTIL_calculateItemTotalCost(fv!item)
                    )
                  }
                ),
                a!textField(
                  value: fv!item.note,
                  saveInto: fv!item.note,
                  characterLimit: 1000,
                  showCharacterCount: false
                  
                ),
                a!textField(
                  value: if(
                    a!isNullOrEmpty(fv!item.unitCost),
                    dollar("0"),
                    dollar(
                      rule!APR_UTIL_calculateItemTotalCost(fv!item)
                    )
                  ),
                  readOnly: true()
                ),
                if(
                  fv!index > local!numberOfExistingItems,
                  a!richTextDisplayField(
                    value: a!richTextIcon(
                      icon: "close",
                      link: a!dynamicLink(
                        value: fv!index,
                        saveInto: {
                          a!save(
                            ri!requestItems,
                            remove(ri!requestItems, save!value)
                          )
                        }
                      ),
                      linkStyle: "STANDALONE",
                      color: "NEGATIVE"
                    )
                  ),
                  if(
                    fv!item.isActive,
                    a!richTextDisplayField(
                      value: a!richTextIcon(
                        icon: "times",
                        altText: "Remove",
                        caption: "Remove",
                        link: a!dynamicLink(
                          value: false(),
                          saveInto: fv!item.isActive
                        ),
                        linkStyle: "STANDALONE"
                      )
                    ),
                    a!richTextDisplayField(
                      value: a!richTextIcon(
                        icon: "undo",
                        altText: "Undo",
                        Caption: "Undo",
                        link: a!dynamicLink(value: true(), saveInto: fv!item.isActive),
                        linkStyle: "STANDALONE"
                      )
                    )
                  )
                )
              }
            )
          ),
          addRowLink: a!dynamicLink(
            label: "Add Item",
            value: 'type!{urn:com:appian:types:APR}APR_Request_Item'(
              partNumber: "",
              description: "",
              quantity: 0,
              unitCost: 0,
              totalCost: 0,
              isActive: true(),
              createdBy: loggedInUser(),
              createdDate: now()
            ),
            saveInto: {
              a!save(
                ri!requestItems,
                append(ri!requestItems, save!value)
              )
            }
            
          ),
          borderStyle: "LIGHT"
        ),
        a!richTextDisplayField(
          label: "Total Cost: ",
          labelPosition: "COLLAPSED",
          value: a!richTextItem(
            text: "Total Cost:   " & dollar(sum(
              a!forEach(
                items: ri!requestItems,
                expression: if(
                  fv!item.isActive,
                  fv!item.totalCost,
                  0
                )
              )
            )),
            style: "STRONG"
          ),
          align: "RIGHT"
          
        )
      }
    )

  • I'd suggest you try and get this working first in a simplified / single interface, then move on from there.

  • 0
    Certified Senior Developer
    in reply to davinar9817

    I think, In grid field we have to refer fv!row to display data. You already stored the data in data parameter in grid field. so we can display only whatever data we have given. 

  • Well I'm mostly just trying to pass a rule input into the interface so I can display it.

    I have this error and I'm not sure why

  • Well, if your child interface is rule!DS_LocalVarAPRTest() as implied by your screenshot - this is not the syntax you'd use to pass a local variable held by the parent.  This is pretty basic syntax for calling Rules in Appian at this point - honestly you might need to go back and review / re-practice the basics.

    Anyway to answer your question, the proper way to call this child interface assuming it has a variable named ri!pkmnChoice which you want to pass the value of local!PokemonChoice, should look like this:

    rule!DS_LocalVarAPRTest(
      pkmnChoice: local!PokemonChoice
    )

  • 0
    Certified Lead Developer

    Hi davinar,

    you storing the selection values in the local variable but that local variable has limited access like it can used between 102 line no to line no 138 and localvariable "local!PokemonChoice" to reference to main local varaible which got initialized in the line 1. Its like nested local variables but no reference from parent varaibles to child variables.