- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2017 03:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2017 04:10 AM
Hi,
In order to make the Related List Mandatory i.e. checking if any record is present in the Related List or not we can make use of an Before Update Business Rule and Abort the Form Submission as required. Please follow the below steps:
1) For Example On the Incident Form, I have the Problem Related List and say based on certain condition you want to check whether the Problem Related List has Records attached or not whether a New one or an existing one then we can have the below script and make the Related List as a mandate one:
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var prb = new GlideRecord("problem");
prb.addEncodedQuery("parent=" + current.sys_id);
prb.query();
if(!prb.next())
{
gs.addInfoMessage("Please link a Problem Record at the bottom Probem Tab");
action.setRedirectURL(current);
current.setAbortAction(true);
}
})(current, previous);
Result:
If the User tries to Update the Record without attaching the Problem Record it aborts the form submission with the Invalid Update Error as shown below:
Hope this helps.Mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2017 03:56 AM
If your query is Resolved, would you mind marking the answer as correct and close the thread.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2017 12:19 PM
Would you mind marking the answer as correct and close the thread so that this can be removed from Unanswered List.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2018 02:06 AM
Hi,
I am trying to achieve the same requirement using your code, here i want to make the outage record mandatory when priority is high. below is my changes in your code which is on condition "before" update or insert. under filter, priority is p1 or p2.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var out = new GlideRecord("cmdb_ci_outage"); /
out.addEncodedQuery("parent=" + current.sys_id);
out.query();
if(!out.next())
{
gs.addErrorMessage("Please link a Outage Record");
current.setAbortAction(true);
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2017 11:24 PM
Hi,
If your Query is Resolved, Mark the answer as correct and close the thread for others.
Regards,
Shloke
Regards,
Shloke