Pranshu5
Giga Contributor

Problem Statement

We have created a M2M table relating Hardware Assets and Requested Item. End user can add multiple HW assets to a HAM Catalog Item to complete a Catalog Task. But once that Catalog Task is completed, the 'Edit...' button should not be available for the user to be able to add/remove anymore assets for future Catalog Tasks execution.

Solution

We have to create a List Control for the M2M table Related List. Utilize 'Omit edit condition' field for scripting to specify the condition(GlideRecord on sc_task table and check 'Closed Complete' state) when the 'Edit...' button should no more be available.

Explanation Steps

1. Created M2M table with 2 reference fields : Requested Item(sc_req_item) & Hardware Asset(alm_hardware)

2. Click the Requested Item form context menu icon and select Configure Related Lists. Using the slushbucket, select the 'Hardware Assets' related list to display on the form.
[We have added UI Policy Related List Action to limit the Related List visibility only on HAM related Requested Items]

3. Open the list context menu in the 'Hardware Assets' related list and select Configure > List Control. Use the Omit edit condition field to configure the scenarios when the 'Edit...' button should no more be visible. Example script:

answer = false;
//For other HAM Catalog Requests
//Close Complete & Close Incomplete - states priority for not showing 'Edit...'
if(parent.state == '3' || parent.state == '4'){
	answer = true;
}
//For HAM Audit catalog Item
else if(parent.cat_item.toString() == '59f837eedbdcdc50ba86abc5ca961959'){
	var catTaskGR = new GlideRecord('sc_task');
	catTaskGR.addQuery('request_item',parent.sys_id.toString());
	catTaskGR.addQuery('short_description','1-Identify Assets to be validated');
	catTaskGR.addQuery('state',3);//Closed Complete
	catTaskGR.query();
	if(catTaskGR.next()){
		answer = true;
	}
}

In the script,
parent = the record on which Related List is added (Ex- Requested Item).
answer = false : 'Edit...' button will be visible
answer = true : 'Edit...' button won't be visible when condition satisfies.

Version history
Last update:
‎04-26-2020 08:11 AM
Updated by: