- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-24-2022 10:29 PM
Hi Experts,
Could you help me in clearing out the latest value in the List collector field of a catalog item.
Example: If user enters some IDS in the field 'Funding Source and Structure (AIM ID(s))' and if the ID was already used it throws an alert on the form i.e 'The last id selected was already used by some other product id, please select other id'.
I was using g_form.clearValue('cat_funding_sources_and_structure'); in an onChange catalog client script to clear the value from the List collector field which is clearing out all the values from the list, only the latest value should be cleared out after the alert is populated.
In the below screenshot, it should remove only the value '31165' (latest)
The screenshot of the alert is below
Please help me in this requirement.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2022 12:25 AM - edited ‎10-25-2022 12:27 AM
Hi @Amit Rao ,
You can use the below script to acheive what you need :
Below your alert() method write the below lines of code:
var selectedValues = g_form.getValue('your_field_name').split(','); //Retreives values selected in the form of array
selectedValues.pop(); // Removes the values selected most recently
g_form.clearValue('your_field_name'); // Clears the field
g_form.setValue('your_field_name',selectedValues.join()); // Repopultes the field with last selected value removed
I Hope this helps.
Please mark this helpful if this helps and Accept the solution if this solves your issue.
Regards,
Kamlesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2022 01:48 AM
Hi Kamlesh,
That worked!
Thanks alot