Skip to main content
February 14, 2024
Question

After unselecting value from picker field the values whatever we selected in editable gird also needs to removed

  • February 14, 2024
  • 3 replies
  • 0 views

Hello,

In user interface we have picker field defined in that if we select one userprofie and later we are calling another subinterface in which we are selecting some products from list and whatever we have selected will be moving to editable grid 

For example in below screen

1.when we are selecting user we will have an option to selected products and link to editable grid which means selected products will be added under Linked products this details was defined in an other interface which we are calling to the current interface

2.If i am removing the user profile means the values from the Linked products which is defined in other interface also has to be removed but it was not removing

Please find the logic available under user profile

 

 saveInto: {
                            a!save(
                              ri!record['recordType!{63a0b9c7-fe03-4c99-8667-a1d9a63acf3f}DIL Users.fields.{d05ec5c4-2ec2-45df-813f-59993f59acd5}profile'],
                              tointeger(save!value)
                            ),
                            if(
                              ri!record['recordType!{63a0b9c7-fe03-4c99-8667-a1d9a63acf3f}DIL Users.fields.{d05ec5c4-2ec2-45df-813f-59993f59acd5}profile'] = tointeger(
                                a!groupsByName("DIL Business Administrators")
                              ),
                              a!save(
                                ri!record['recordType!{63a0b9c7-fe03-4c99-8667-a1d9a63acf3f}DIL Users.relationships.{dce90eec-778e-4242-9525-6e284c59b8dc}dilProductUserTrans.fields.{c439a729-191b-48b1-8c03-00845980893a}access'],
                                "AU"
                              ),
                              {}
                            ),
                            a!save(ri!userProfile,
                            tointeger(save!value)),
                            a!save(ri!productUserTrans,
                            if(
                              a!isNullOrEmpty(ri!userProfile),
                              {},
                              ri!productUserTrans
                            ))
                          },

Logic available in Liked products

 selectionSaveInto:{local!selectedDataIndex,
                      if(
                        a!isNullOrEmpty(ri!userProfile),
                        a!save(local!selectedList, {}),
                        local!selectedDataIndex
                        ),
                      /* Clear out choices */
                      if(
                        
                        a!isNullOrEmpty(ri!userProfile),
                        a!save(local!selectedDataIndex, null),
                        local!selectedDataIndex),
                      if(
                        a!isNullOrEmpty(ri!userProfile),
                        a!save(ri!productUserTrans, null()),
                        local!selectedDataIndex
                        )
                        },

In the Main interface(where user profile define) the values are nullified but in the sub interface the values remains same

Please suggest on this

3 replies

stefanhelzle0001
Brainy
February 14, 2024

Could it be that this component uses some local variables to manage state?

konduruc733182
February 14, 2024

Hello [mention:bfd227c27aea444eb49c1c9c963d1ba5:e9ed411860ed4f2ba0265705b8793d05] 

Could you please show us the Code from your DIL Products interface.

February 15, 2024

a!localVariables(
  local!availableDataIndex,
  local!selectedDataIndex,
  local!selectedList,
  local!availableList: a!queryRecordType(
    recordType: 'recordType!{c47abb37-84f0-49eb-9b58-ae53de0b1b0e}DIL Product Master Record',
    fields: {
      'recordType!{c47abb37-84f0-49eb-9b58-ae53de0b1b0e}DIL Product Master Record.relationships.{a942a3af-e482-44d5-8b81-7f2b396805a6}dilProductUserTrans'
    },
    pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 100)
  ).data,
  local!pickedProduct,
  local!pickSelectedProduct,
  local!access,
  {
    a!sectionLayout(
      contents: {
        a!richTextDisplayField(
          value: a!richTextHeader(text: "DIL Products", size: "MEDIUM")
        ),
        a!columnsLayout(
          columns: {
            a!columnLayout(
              contents: {
                a!cardLayout(
                  contents: {
                    a!pickerFieldCustom(
                      label: "Products",
                      labelPosition: "ABOVE",
                      suggestFunction: rule!DIL_arrayPickerFilter(
                        filter: _,
                        labels: local!availableList['recordType!{c47abb37-84f0-49eb-9b58-ae53de0b1b0e}DIL Product Master Record.fields.{d5cdf456-ad11-4102-8949-444cea5e1ff1}dilProduct'],
                        identifiers: local!availableList['recordType!{c47abb37-84f0-49eb-9b58-ae53de0b1b0e}DIL Product Master Record.fields.{7fd8b879-c6ec-433f-8556-555835af5fbd}id']
                      ),
                      selectedLabels: a!forEach(
                        items: local!pickedProduct,
                        expression: index(
                          local!availableList['recordType!{c47abb37-84f0-49eb-9b58-ae53de0b1b0e}DIL Product Master Record.fields.{d5cdf456-ad11-4102-8949-444cea5e1ff1}dilProduct'],
                          wherecontains(
                            tointeger(fv!item),
                            tointeger(
                              local!availableList['recordType!{c47abb37-84f0-49eb-9b58-ae53de0b1b0e}DIL Product Master Record.fields.{7fd8b879-c6ec-433f-8556-555835af5fbd}id']
                            )
                          )
                        )
                      ),
                      value: local!pickedProduct,
                      saveInto: {
                        local!pickedProduct,
                        a!save(
                          local!availableList,
                          a!queryRecordType(
                            recordType: 'recordType!{c47abb37-84f0-49eb-9b58-ae53de0b1b0e}DIL Product Master Record',
                            filters: {
                              a!queryFilter(
                                field: 'recordType!{c47abb37-84f0-49eb-9b58-ae53de0b1b0e}DIL Product Master Record.fields.{7fd8b879-c6ec-433f-8556-555835af5fbd}id',
                                operator: "in",
                                value: tointeger(local!pickedProduct),
                                applyWhen: a!isNotNullOrEmpty(local!pickedProduct)
                              )
                            },
                            pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 100)
                          ).data
                        )/*a!save(*/
                        /*local!availableList,*/
                        /*remove(*/
                        /*local!availableList,*/
                        /*if(*/
                        /*rule!APN2_isBlank(local!selectedList),*/
                        /*{},*/
                        /*wherecontains(local!selectedList, local!availableList)*/
                        /*)*/
                        /*)*/
                        /*)*/
                        
                      },
                      validations: {}
                    ),
                    a!gridLayout(
                      headerCells: { "" },
                      rows: a!forEach(
                        local!availableList,
                        a!gridRowLayout(
                          id: fv!index,
                          contents: {
                            a!textField(
                              value: fv!item['recordType!{c47abb37-84f0-49eb-9b58-ae53de0b1b0e}DIL Product Master Record.fields.{d5cdf456-ad11-4102-8949-444cea5e1ff1}dilProduct'],
                              readOnly: true()
                            )
                          }
                        )
                      ),
                      selectionValue: local!availableDataIndex,
                      selectionSaveInto: local!availableDataIndex,
                      selectable: togroup(
                        ri!record['recordType!{63a0b9c7-fe03-4c99-8667-a1d9a63acf3f}DIL Users.fields.{d05ec5c4-2ec2-45df-813f-59993f59acd5}profile']
                      ) = a!groupsByName("DIL Users"),
                      selectionStyle: "ROW_HIGHLIGHT",
                      validations: {}
                    )
                  },
                  height: "TALL",
                  style: "NONE",
                  marginBelow: "STANDARD"
                )
              },
              width: "MEDIUM"
            ),
            a!columnLayout(
              contents: {
                a!buttonArrayLayout(
                  buttons: {
                    a!buttonWidget_23r3(
                      label: "LINK",
                      style: "SECONDARY",
                      disabled: or(
                        a!isNullOrEmpty(local!availableDataIndex),
                        count(local!availableList) = 0
                      ),
                      saveInto: {
                        /* Add chosen available items to selected list */
                        a!save(
                          local!selectedList,
                          append(
                            local!selectedList,
                            index(
                              local!availableList,
                              local!availableDataIndex,
                              {}
                            )
                          )
                        ),
                        /* Remove from available list */
                        a!save(
                          local!availableList,
                          remove(
                            local!availableList,
                            local!availableDataIndex
                          )
                        ),
                        /* Clear out choices */
                        a!save(local!availableDataIndex, null),
                        a!save(ri!record['recordType!{63a0b9c7-fe03-4c99-8667-a1d9a63acf3f}DIL Users.relationships.{dce90eec-778e-4242-9525-6e284c59b8dc}dilProductUserTrans.fields.{c439a729-191b-48b1-8c03-00845980893a}access'],null()),
                        /*a!save(local!pickedProduct,null),*/
                        a!save(
                          local!access,
                          index(
                            local!selectedList[1],
                            'recordType!{63a0b9c7-fe03-4c99-8667-a1d9a63acf3f}DIL Users.relationships.{dce90eec-778e-4242-9525-6e284c59b8dc}dilProductUserTrans',
                            null
                          )[1]['recordType!{4e3af057-0819-4e51-901a-b1f7328997fb}DIL Product User Trans.fields.{c439a729-191b-48b1-8c03-00845980893a}access']
                        ),
                        a!save(
                          ri!productUserTrans,
                          a!forEach(
                            local!selectedList,
                            'recordType!{4e3af057-0819-4e51-901a-b1f7328997fb}DIL Product User Trans'(
                              'recordType!{4e3af057-0819-4e51-901a-b1f7328997fb}DIL Product User Trans.fields.{b0c9f1de-b36b-4afa-a6c9-9e0d6a8d66c8}productId': fv!item['recordType!{c47abb37-84f0-49eb-9b58-ae53de0b1b0e}DIL Product Master Record.fields.{7fd8b879-c6ec-433f-8556-555835af5fbd}id'],
                              'recordType!{4e3af057-0819-4e51-901a-b1f7328997fb}DIL Product User Trans.fields.{ab90946c-3a00-48e8-bcaf-cc3b1ce00479}userId': ri!record['recordType!{63a0b9c7-fe03-4c99-8667-a1d9a63acf3f}DIL Users.fields.{27db380a-2a73-451f-9a40-96a5c543624b}id'],
                              'recordType!{4e3af057-0819-4e51-901a-b1f7328997fb}DIL Product User Trans.fields.{c439a729-191b-48b1-8c03-00845980893a}access': if(
                                and(a!isNullOrEmpty(index(
                                  fv!item,
                                  'recordType!{63a0b9c7-fe03-4c99-8667-a1d9a63acf3f}DIL Users.relationships.{dce90eec-778e-4242-9525-6e284c59b8dc}dilProductUserTrans',
                                  null()
                                )[1]['recordType!{4e3af057-0819-4e51-901a-b1f7328997fb}DIL Product User Trans.fields.{c439a729-191b-48b1-8c03-00845980893a}access']),ri!allOpen="AU"),
                                "U",
                                if(
                                  and(a!isNullOrEmpty(index(
                                    fv!item,
                                    'recordType!{63a0b9c7-fe03-4c99-8667-a1d9a63acf3f}DIL Users.relationships.{dce90eec-778e-4242-9525-6e284c59b8dc}dilProductUserTrans',
                                    null()
                                  )[1]['recordType!{4e3af057-0819-4e51-901a-b1f7328997fb}DIL Product User Trans.fields.{c439a729-191b-48b1-8c03-00845980893a}access']),ri!allBinded="AB"),
                                  "B",
                                  if(
                                    a!isNullOrEmpty(
                                      index(
                                        fv!item,
                                        'recordType!{63a0b9c7-fe03-4c99-8667-a1d9a63acf3f}DIL Users.relationships.{dce90eec-778e-4242-9525-6e284c59b8dc}dilProductUserTrans',
                                        null()
                                      )[1]['recordType!{4e3af057-0819-4e51-901a-b1f7328997fb}DIL Product User Trans.fields.{c439a729-191b-48b1-8c03-00845980893a}access']
                                    ),
                                    "B",
                                    index(
                                      fv!item,
                                      'recordType!{63a0b9c7-fe03-4c99-8667-a1d9a63acf3f}DIL Users.relationships.{dce90eec-778e-4242-9525-6e284c59b8dc}dilProductUserTrans',
                                      null()
                                    )[1]['recordType!{4e3af057-0819-4e51-901a-b1f7328997fb}DIL Product User Trans.fields.{c439a729-191b-48b1-8c03-00845980893a}access']
                                  )

                                ),

                              ),
                              'recordType!{4e3af057-0819-4e51-901a-b1f7328997fb}DIL Product User Trans.fields.{9c2b75ca-2fc6-450d-9607-2e418206f6c9}isActive': 1
                            )
                          )
                        ),
                        
                      },
                      icon: if(
                        a!isPageWidth("PHONE"),
                        "chevron-down",
                        "chevron-right"
                      ),
                      width: "FILL"
                    ),
                    a!buttonWidget_23r3(
                      label: "LINK ALL",
                      style: "SECONDARY",
                      disabled: count(local!availableList) = 0,
                      saveInto: {
                        /* Add all available items to selected list */
                        a!save(
                          local!selectedList,
                          append(local!selectedList, local!availableList)
                        ),
                        /* Clear available list */
                        a!save(local!availableList, {}),
                        /* Clear out choices */
                        a!save(local!availableDataIndex, null),
                        a!save(
                          local!access,
                          index(
                            local!selectedList[1],
                            'recordType!{63a0b9c7-fe03-4c99-8667-a1d9a63acf3f}DIL Users.relationships.{dce90eec-778e-4242-9525-6e284c59b8dc}dilProductUserTrans',
                            null
                          )[1]['recordType!{4e3af057-0819-4e51-901a-b1f7328997fb}DIL Product User Trans.fields.{c439a729-191b-48b1-8c03-00845980893a}access']
                        ),
                        a!save(
                          ri!productUserTrans,
                          a!forEach(
                            local!selectedList,
                            'recordType!{4e3af057-0819-4e51-901a-b1f7328997fb}DIL Product User Trans'(
                              'recordType!{4e3af057-0819-4e51-901a-b1f7328997fb}DIL Product User Trans.fields.{ab90946c-3a00-48e8-bcaf-cc3b1ce00479}userId': ri!record['recordType!{63a0b9c7-fe03-4c99-8667-a1d9a63acf3f}DIL Users.fields.{27db380a-2a73-451f-9a40-96a5c543624b}id'],
                              'recordType!{4e3af057-0819-4e51-901a-b1f7328997fb}DIL Product User Trans.fields.{b0c9f1de-b36b-4afa-a6c9-9e0d6a8d66c8}productId': fv!item['recordType!{c47abb37-84f0-49eb-9b58-ae53de0b1b0e}DIL Product Master Record.fields.{7fd8b879-c6ec-433f-8556-555835af5fbd}id'],
                              'recordType!{4e3af057-0819-4e51-901a-b1f7328997fb}DIL Product User Trans.fields.{c439a729-191b-48b1-8c03-00845980893a}access': if(
                                a!isNullOrEmpty(index(
                                  fv!item,
                                  'recordType!{63a0b9c7-fe03-4c99-8667-a1d9a63acf3f}DIL Users.relationships.{dce90eec-778e-4242-9525-6e284c59b8dc}dilProductUserTrans',
                                  null
                                )[1]['recordType!{4e3af057-0819-4e51-901a-b1f7328997fb}DIL Product User Trans.fields.{c439a729-191b-48b1-8c03-00845980893a}access']),
                                "B",
                                index(
                                  fv!item,
                                  'recordType!{63a0b9c7-fe03-4c99-8667-a1d9a63acf3f}DIL Users.relationships.{dce90eec-778e-4242-9525-6e284c59b8dc}dilProductUserTrans',
                                  null
                                )[1]['recordType!{4e3af057-0819-4e51-901a-b1f7328997fb}DIL Product User Trans.fields.{c439a729-191b-48b1-8c03-00845980893a}access']
                              ),
                              'recordType!{4e3af057-0819-4e51-901a-b1f7328997fb}DIL Product User Trans.fields.{9c2b75ca-2fc6-450d-9607-2e418206f6c9}isActive': 1
                            )
                          )
                        )
                      },
                      icon: "plus",
                      width: "FILL"
                    )
                  },
                  align: "START",
                  marginBelow: "EVEN_MORE"
                ),
                a!buttonArrayLayout(
                  buttons: {
                    a!buttonWidget_23r3(
                      label: "UNLINK",
                      style: "SECONDARY",
                      disabled: or(
                        a!isNullOrEmpty(local!selectedDataIndex),
                        length(local!selectedList) = 0
                      ),
                      saveInto: {
                        /* Add chosen selected items to available list */
                        a!save(
                          local!availableList,
                          append(
                            local!availableList,
                            index(
                              local!selectedList,
                              local!selectedDataIndex,
                              {}
                            )
                          )
                        ),
                        /* Remove from selected list */
                        a!save(
                          local!selectedList,
                          remove(
                            local!selectedList,
                            local!selectedDataIndex
                          )
                        ),
                        a!save(
                          ri!productUserTrans,
                          remove(
                            ri!productUserTrans,
                            local!selectedDataIndex
                          )
                        ),
                        
                        /* Clear out choices */
                        a!save(local!selectedDataIndex, null),
                        
                      },
                      icon: if(
                        a!isPageWidth("PHONE"),
                        "chevron-up",
                        "chevron-left"
                      ),
                      width: "FILL"
                    ),
                    a!buttonWidget_23r3(
                      label: "UNLINK ALL",
                      style: "SECONDARY",
                      disabled: count(local!selectedList) = 0,
                      saveInto: {
                        /* Add all selected items to available list */
                        a!save(
                          local!availableList,
                          append(local!selectedList, local!availableList)
                        ),
                        /* Clear selected list */
                        a!save(local!selectedList, {}),
                        /* Clear out choices */
                        a!save(local!selectedDataIndex, null),
                        a!save(ri!productUserTrans, null())
                      },
                      icon: "times",
                      width: "FILL"
                    )
                  },
                  align: "START"
                )
              },
              width: "NARROW"
            ),
            a!columnLayout(
              contents: {
                a!cardLayout(
                  contents: {
                    a!pickerFieldCustom(
                      label: "Linked Products",
                      labelPosition: "ABOVE",
                      suggestFunction: rule!DIL_arrayPickerFilter(
                        filter: _,
                        labels: local!selectedList['recordType!{c47abb37-84f0-49eb-9b58-ae53de0b1b0e}DIL Product Master Record.fields.{d5cdf456-ad11-4102-8949-444cea5e1ff1}dilProduct'],
                        identifiers: local!selectedList['recordType!{c47abb37-84f0-49eb-9b58-ae53de0b1b0e}DIL Product Master Record.fields.{7fd8b879-c6ec-433f-8556-555835af5fbd}id']
                      ),
                      selectedLabels: a!forEach(
                        items: local!pickSelectedProduct,
                        expression: index(
                          local!selectedList['recordType!{c47abb37-84f0-49eb-9b58-ae53de0b1b0e}DIL Product Master Record.fields.{d5cdf456-ad11-4102-8949-444cea5e1ff1}dilProduct'],
                          wherecontains(
                            tointeger(fv!item),
                            tointeger(
                              local!selectedList['recordType!{c47abb37-84f0-49eb-9b58-ae53de0b1b0e}DIL Product Master Record.fields.{7fd8b879-c6ec-433f-8556-555835af5fbd}id']
                            )
                          )
                        )
                      ),
                      value: local!pickSelectedProduct,
                      saveInto: {
                        local!pickSelectedProduct,
                        a!save(
                          local!selectedList,
                          a!queryRecordType(
                            recordType: 'recordType!{c47abb37-84f0-49eb-9b58-ae53de0b1b0e}DIL Product Master Record',
                            filters: {
                              a!queryFilter(
                                field: 'recordType!{c47abb37-84f0-49eb-9b58-ae53de0b1b0e}DIL Product Master Record.fields.{7fd8b879-c6ec-433f-8556-555835af5fbd}id',
                                operator: "in",
                                value: tostring(local!pickSelectedProduct),
                                applyWhen: a!isNotNullOrEmpty(local!pickSelectedProduct)
                              )
                            },
                            pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 100)
                          ).data
                        ),
                        a!save(
                          local!selectedList,
                          remove(
                            local!selectedList,
                            if(
                              rule!APN2_isBlank(local!availableList),
                              {},
                              wherecontains(local!availableList, local!selectedList)
                            )
                          )
                        )
                      },
                      validations: {}
                    ),
                    a!gridLayout(
                      emptyGridMessage: " ",
                      headerCells: {
                        a!gridLayoutHeaderCell(label: ""),
                        a!gridLayoutHeaderCell(label: "")
                      },
                      columnConfigs: { a!gridLayoutColumnConfig(width: "ICON") },
                      rows: a!forEach(
                        local!selectedList,
                        a!gridRowLayout(
                          id: fv!index,
                          contents: {
                            a!radioButtonField_23r3(
                              choiceLabels: { "B", "U" },
                              choiceValues: { "B", "U" },
                              value:  if(
                                a!isNullOrEmpty(fv!item['recordType!{c47abb37-84f0-49eb-9b58-ae53de0b1b0e}DIL Product Master Record.relationships.{a942a3af-e482-44d5-8b81-7f2b396805a6}dilProductUserTrans.fields.{c439a729-191b-48b1-8c03-00845980893a}access']),
                                "B",
                                if(
                                  ri!allOpen="AU",
                                  "U",
                                  fv!item['recordType!{c47abb37-84f0-49eb-9b58-ae53de0b1b0e}DIL Product Master Record.relationships.{a942a3af-e482-44d5-8b81-7f2b396805a6}dilProductUserTrans.fields.{c439a729-191b-48b1-8c03-00845980893a}access']
                                )),
                                saveInto: {
                                  fv!item['recordType!{c47abb37-84f0-49eb-9b58-ae53de0b1b0e}DIL Product Master Record.relationships.{a942a3af-e482-44d5-8b81-7f2b396805a6}dilProductUserTrans.fields.{c439a729-191b-48b1-8c03-00845980893a}access'],
                                  a!save(
                                    ri!productUserTrans[fv!index]['recordType!{4e3af057-0819-4e51-901a-b1f7328997fb}DIL Product User Trans.fields.{c439a729-191b-48b1-8c03-00845980893a}access'],
                                    save!value
                                  ),
                                  a!save(
                                    local!selectedList,
                                    if(a!isNullOrEmpty(ri!userProfile),
                                    null,
                                    {})
                                  ),
                                  a!save(
                                    ri!productUserTrans,
                                    if(a!isNullOrEmpty(ri!userProfile),
                                    null,
                                    {})
                                  )
                                  
                                },
                                disabled: if(
                                  or(ri!allOpen="AU",
                                 ri!allBinded="AB" ),
                                true(),false),
                              choiceLayout: "COMPACT"
                            ),
                            a!textField(
                              value: fv!item['recordType!{c47abb37-84f0-49eb-9b58-ae53de0b1b0e}DIL Product Master Record.fields.{d5cdf456-ad11-4102-8949-444cea5e1ff1}dilProduct'],
                              readOnly: true()
                            )
                          }
                        )
                      ),
                      selectionValue: local!selectedDataIndex,
                      selectionSaveInto:local!selectedDataIndex,
                      /*{local!selectedDataIndex,*/
                      /*if(*/
                        /*a!isNullOrEmpty(ri!userProfile),*/
                        /*a!save(local!selectedList, {}),*/
                        /*local!selectedDataIndex*/
                        /*),*/
                      /* Clear out choices */
                      /*if(*/
/*                        */
                        /*a!isNullOrEmpty(ri!userProfile),*/
                        /*a!save(local!selectedDataIndex, null),*/
                        /*local!selectedDataIndex),*/
                      /*if(*/
                        /*a!isNullOrEmpty(ri!userProfile),*/
                        /*a!save(ri!productUserTrans, null()),*/
                        /*local!selectedDataIndex*/
                        /*)*/
                        /*},*/
                      selectable: true(),
                      selectionStyle: "ROW_HIGHLIGHT",
                      validations: {
                        /*if(*/
                        /*a!isNullOrEmpty(local!selectedList),*/
                        /*"At least one DIL Product is required",*/
                        /*null*/
                        /*),*/
                        
                      }
                    )
                  },
                  height: "TALL",
                  marginBelow: "STANDARD"
                )
              },
              width: "MEDIUM"
            ),
            a!columnLayout(contents: {})
          },
          alignVertical: "MIDDLE"
        ),
        a!buttonArrayLayout(
          buttons: a!buttonWidget_23r3(
            label: "Link",
            value: "SAVE",
            saveInto: { a!save(ri!button, "SAVE") },
            showWhen: ri!actionType="LinkProducts",
            submit: true,

          )
        )
      },
      showWhen: not(ri!newUser = "CreateUser")
    )
  }
)

PFA