Remove the selected record from the Custom Picker List

Certified Associate Developer

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))
),
)
)

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    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)
          )
        ),
    
      )
    )

Reply
  • 0
    Certified Lead Developer

    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)
          )
        ),
    
      )
    )

Children
No Data