Error while fixing a bug in dropdown

Certified Senior Developer

Hi,

"Expression evaluation error [evaluation ID = c3662:90d03] in rule 'bc_frm_addasset' at function a!dropdownField [line 114]: A null parameter has been passed.".

An user cannot edit an asset when an UoM is deactivated. For eg. if Meters is deactivated in UoM reference table, then an user trying to edit an asset with 78 Meters as quantity can't edit the asset as it throws an error. 

So I am trying to use intersection function but getting the above error.  Any suggestions how to fix this? 

TIA

a!dropdownField(
                          label: "Unit of Measure",
                          labelPosition: "ABOVE",
                          placeholder: cons!BC_TEXT_PLACE_HOLDER_SELECT_VALUE,
                          choiceLabels: property(
                            local!unitOfMeasurementList,
                            "description",
                            null
                          ),
                          choiceValues: property(
                            local!unitOfMeasurementList,
                            "measureId",
                            null
                          ),
                          value: intersection(tointeger(ri!asset.unitOfMeasureId),tointeger(local!unitOfMeasurementList.measureId)),
                          saveInto: { ri!asset.unitOfMeasureId },
                          required: true,
                          validations: {}
                        )

  Discussion posts and replies are publicly visible

Parents
  • Your choice values are active UoM ( assuming query from DB with parameter isActive = true).
    Solution:
    When a new request is going to be created then query as isActive = true.

    In any existing request, any task or related action query regardless of isActive and just display as a tool tool tip or something just saying the selected option is no more available for new request. Its been deactivated and will be available for this request only.

    Or as per business, you can force them to pick the active one only if anyone is editing it.

  • 0
    Certified Senior Developer
    in reply to Dhananjay Kumar

    Thank you for your suggestion Dhananjay. This is valid for any new asset addition. 

    I am talking about editing already existing entries with now deactivated UoM. 

    for eg. I have deactivated the UoM cp.

    There are assets with cp as UoM.

    If I go to that particular asset for editing, I won't be able to edit it since I get an error message:

    "A dropdown component [label="Unit of Measure"] has an invalid value for "value". All selected values must be present in the choiceValues array, but value was 7 and choiceValues was 1; 2; 3; 4; 5; 6" because measureID 7 is deactivated now. 

    I am trying to find a solution to avoid the error and replace the UoM cp to blank UoM in all the related assets. 

    Hope you get what I am trying to do. 

  • 0
    Certified Lead Developer
    in reply to Sandhya

    If I go to that particular asset for editing, I won't be able to edit it since I get an error message:
    You are not able to see because you are querying from only the activated one.  Query inactive and active both.


    And let user edit. and proceed.

    and why I am asking to query both active and deactivated because the already selected one is deactivated now.

    If a request having active UoM then no need to query deactivated one. just query activated one.

  • +1
    Certified Lead Developer
    in reply to Sandhya

    I would be interested what your requirements are from a business perspective. Denying the use of a disabled UoM for an article which had it assigned in the past might become a problem.

    But to check whether the value assigned to the article is in the available values of the drop down, can easily be done using an if() and contains(). So, if the value is not present in the choices, assign null as a value.

  • 0
    Certified Senior Developer
    in reply to Stefan Helzle

    Hi Stefan,

    There could be a scenario where the business user may have an admin tool to activate/deactivate UoM. In that case, this bug can be expected. 

    Will try what you suggested for dropdown. 

    Thanks

Reply Children
No Data