Skip to main content
March 6, 2023
Question

Remove the selected record from the Custom Picker List

  • March 6, 2023
  • 5 replies
  • 0 views

Hi I would like to remove the selected record from the Custom Picker. But the below code throws error.

In code labels and identifiers are same as i need only name.

Code Snippet:

a!localVariables(
local!selIndex,
local!selItem,
local!selectedRecord:rule!ACRA_GetExistingInfo(),
local!currentRecords:a!refreshVariable(
value:if(a!isNullOrEmpty(ri!selectedProducts),
null(),
ri!selectedProducts),
refreshOnReferencedVarChange: true
),
local!recordLabels: a!refreshVariable(
value:if(a!isNullOrEmpty(local!currentRecords),
local!selectedRecord.proposedName,
remove(local!selectedRecord,
tointeger(wherecontains(
touniformstring(local!currentRecords.proposedName),
touniformstring(local!selectedRecord.proposedName)
))).proposedName
),
refreshOnReferencedVarChange: true
),
/*local!recordLabels:local!selectedRecord.proposedName,*/
local!newRow:'type!{urn:com:appian:types:ACRA}ACRA_ProposedNamesInfo'(),
local!products:'type!{urn:com:appian:types:ACRA}ACRA_ProposedNamesInfo'(),
a!gridLayout(
label: "Editable Grid",
labelPosition: "ABOVE",
headerCells: {
a!gridLayoutHeaderCell(label: "Id"),
a!gridLayoutHeaderCell(label: "Picker"),
a!gridLayoutHeaderCell(label: "Selected Name"),
},
columnConfigs: {
a!gridLayoutColumnConfig(width:"DISTRIBUTE", weight:5),
a!gridLayoutColumnConfig(width:"DISTRIBUTE", weight:5),
a!gridLayoutColumnConfig(width:"DISTRIBUTE", weight:5),
},
rows: {
a!forEach(
items:ri!selectedProducts,
expression: a!gridRowLayout(
contents:{
a!textField(
value: if(a!isNullOrEmpty(fv!item.proposedName),{},fv!item.pId),
saveInto: fv!item.pId
),
a!pickerFieldCustom(
label: "Names",
instructions: "Enter the name.",
maxSelections: 1,
suggestFunction: rule!ucArrayPickerFilter(filter: _, labels: local!recordLabels, identifiers: local!recordLabels),
selectedLabels: a!forEach(
items: fv!item.proposedName,
expression: index(
local!recordLabels,
wherecontains(
touniformstring(fv!item),
touniformstring(local!recordLabels)
)
)
),
value: fv!item.proposedName,
saveInto: {
a!save(fv!item.proposedName, save!value),
a!save(local!products,rule!ACRA_GetProductsByName(pname:fv!item.proposedName)),
a!save(fv!item.pId, local!products.pId),
a!save(fv!item.status, local!products.status),
a!save(local!selItem,fv!item),
/*a!save(local!selIndex,*/
/*tointeger(wherecontains(*/
/*touniformstring(fv!item.proposedName), */
/*touniformstring(local!recordLabels)*/
/*))*/
/*),*/
/*a!save(local!recordLabels,remove(local!recordLabels,*/
/*tointeger(wherecontains(*/
/*touniformstring(fv!item.proposedName), */
/*touniformstring(local!recordLabels)*/
/*)))),*/
}
),
a!textField(
value: if(a!isNullOrEmpty(fv!item.proposedName),{},fv!item.status),
saveInto: fv!item.status
),

}
)
)
},
addRowLink: a!dynamicLink(
label:"Add Row",
saveInto: a!save(ri!selectedProducts,
append(ri!selectedProducts, local!newRow))
),
)
)

5 replies

stefanhelzle0001
Brainy
March 6, 2023

Your code in a more readable way:

a!localVariables(
  local!selIndex,
  local!selItem,
  local!selectedRecord: rule!ACRA_GetExistingInfo(),
  local!currentRecords: a!refreshVariable(
    value: if(
      a!isNullOrEmpty(ri!selectedProducts),
      null(),
      ri!selectedProducts
    ),
    refreshOnReferencedVarChange: true
  ),
  local!recordLabels: a!refreshVariable(
    value: if(
      a!isNullOrEmpty(local!currentRecords),
      local!selectedRecord.proposedName,
      remove(
        local!selectedRecord,
        tointeger(
          wherecontains(
            touniformstring(local!currentRecords.proposedName),
            touniformstring(local!selectedRecord.proposedName)
          )
        )
      ).proposedName
    ),
    refreshOnReferencedVarChange: true
  ),
  /*local!recordLabels:local!selectedRecord.proposedName,*/
  local!newRow: 'type!{urn:com:appian:types:ACRA}ACRA_ProposedNamesInfo'(),
  local!products: 'type!{urn:com:appian:types:ACRA}ACRA_ProposedNamesInfo'(),
  a!gridLayout(
    label: "Editable Grid",
    labelPosition: "ABOVE",
    headerCells: {
      a!gridLayoutHeaderCell(label: "Id"),
      a!gridLayoutHeaderCell(label: "Picker"),
      a!gridLayoutHeaderCell(label: "Selected Name"),

    },
    columnConfigs: {
      a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 5),
      a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 5),
      a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 5),

    },
    rows: {
      a!forEach(
        items: ri!selectedProducts,
        expression: a!gridRowLayout(
          contents: {
            a!textField(
              value: if(
                a!isNullOrEmpty(fv!item.proposedName),
                {},
                fv!item.pId
              ),
              saveInto: fv!item.pId
            ),
            a!pickerFieldCustom(
              label: "Names",
              instructions: "Enter the name.",
              maxSelections: 1,
              suggestFunction: rule!ucArrayPickerFilter(
                filter: _,
                labels: local!recordLabels,
                identifiers: local!recordLabels
              ),
              selectedLabels: a!forEach(
                items: fv!item.proposedName,
                expression: index(
                  local!recordLabels,
                  wherecontains(
                    touniformstring(fv!item),
                    touniformstring(local!recordLabels)
                  )
                )
              ),
              value: fv!item.proposedName,
              saveInto: {
                a!save(fv!item.proposedName, save!value),
                a!save(
                  local!products,
                  rule!ACRA_GetProductsByName(pname: fv!item.proposedName)
                ),
                a!save(fv!item.pId, local!products.pId),
                a!save(fv!item.status, local!products.status),
                a!save(local!selItem, fv!item),
                /*a!save(local!selIndex,*/
                /*tointeger(wherecontains(*/
                /*touniformstring(fv!item.proposedName), */
                /*touniformstring(local!recordLabels)*/
                /*))*/
                /*),*/
                /*a!save(local!recordLabels,remove(local!recordLabels,*/
                /*tointeger(wherecontains(*/
                /*touniformstring(fv!item.proposedName), */
                /*touniformstring(local!recordLabels)*/
                /*)))),*/

              }
            ),
            a!textField(
              value: if(
                a!isNullOrEmpty(fv!item.proposedName),
                {},
                fv!item.status
              ),
              saveInto: fv!item.status
            ),

          }
        )
      )
    },
    addRowLink: a!dynamicLink(
      label: "Add Row",
      saveInto: a!save(
        ri!selectedProducts,
        append(ri!selectedProducts, local!newRow)
      )
    ),

  )
)

July 26, 2024

Was this issue ever resolved?

konduruc733182
July 28, 2024

What is the issue that you are facing? Is it the same error that is displayed above. Please share your code.

July 28, 2024

I discovered the issue was related to some nested for loops that were being used to call some interfaces