- 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-11-2017 04:11 AM
You need to write a business rule on the change_request table to validate that there is a change verification record in the related table or else abort the change processing
Thank You
Please Hit Like, Helpful or Correct depending on the impact of response
- 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-11-2017 11:21 PM
I have verification list on the change form, which contains user to be added on the related list.
I wrote the below business rule but does not work out.
Script: (function executeRule(current, previous /*null when async*/) { // Add your code here var usr = new GlideRecord("sys_user"); usr.addEncodedQuery("parent=" + current.sys_id); usr.query(); if(!usr.next()) { gs.addInfoMessage("Please link a Problem Record at the bottom Verification Tab"); action.setRedirectURL(current); current.setAbortAction(true); } })(current, previous) It throws error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2017 02:03 AM
Hi,
Everything looks good in the script shared above except the Table Name in your Glide Record Query i.e. it should not be User(sys_user) table but it should be the Related List Table i.e. Verification Table in your scenario where you are trying to add the User Record on the Parent Change form. Update the Correct Table Name in the Query and try the below script again to check for the functionality.
Update your Code as per the below mentioned:
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var usr = new GlideRecord("Table Name"); //Replace here the Related List table i.e Table where you are adding the User Record on Change Form
usr.addEncodedQuery("parent=" + current.sys_id);
usr.query();
if(!usr.next())
{
gs.addInfoMessage("Please link a User Record at the bottom Verification Tab");
action.setRedirectURL(current);
current.setAbortAction(true);
}
})(current, previous);
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:27 AM
Perfect