- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2024 11:21 AM
Hello! Just had a question I was hoping to get some guidance on as I am relatively new to the ServiceNow environment.
The Profit Center field references a Profit Center table
The Fund field references a different table that includes Profit Centers
Both fields are pre-populated
What I'm wondering is if there is a way to restrict the Fund field choices to only show Funds that are related to that specific Profit Center populated? Also, when the form is in a specific status, the Fund field should be cleared out and require that new selection. So I was also wondering how I would go about doing that as well. Thank you for your time!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2024 02:57 PM - edited 09-18-2024 02:58 PM
What exactly is meant by status field. Is it a field.
If Yes,
You can write a on change client script to clear the value.
Navigate to Client scripts:
Select new,
Table: Select the table
Type : On Change
Field name: SELECT THE STATUS FIELD
Write the below script
Hope this helps. Kindly mark it as Helpful and Accept the solution.
Regards,
Najmuddin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2024 11:35 AM
Hi @ndejoya ,
For this requirement, you need to write a advanced reference qualifier which calls a script include with input Profit center. (You pass the value of the profit center to the script Include.)
In script include,
you will query the fund table filtering the profit center.
While you have those records, push those records sys_id in an array and return the array.
If this helps you kindly mark it as Helpful and Accept the solution.
Regards,
Najmuddin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2024 11:41 AM
Hello! Thank you for your response, do you know how this advanced reference qualifier and script include would look? I have not worked with that yet as I am new to the environment. Thank you for your time!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2024 11:49 AM - edited 09-18-2024 11:53 AM
Hi @ndejoya ,
Navigate to Script Includes > Create New.
Check box: Client callable
Name: Fund
Something similar to this.
Script Include: Fund
write the below script.
var Fund = Class.create();
Fund.prototype = {
initialize: function() {},
fundValues: function(profit) {
var array = [];
var gr = new GlideRecord(TABLE_NAME_OF_PROFIT);
gr.addQuery('VARIABLE_NAME_THAT_H0LDS_PROFIT_VALUE', profit);
gr.query();
while (gr.next()) {
array.push(gr.getValue('sys_id')); // get the sys_id of the records.
}
return array;
},
type: 'Fund'
};
Advance Reference Qualifier:
Now, right click on the Fund field, configure dictionary,
Then in the related links, click Advance View.
In the Reference Specification section,
Select Advance,
In the Reference qual:
Hope this helps.
Regards,
Najmuddin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2024 12:05 PM
Wow, this has been very helpful. Thank you! My last question would be, since the Fund value is prepopulated on the form, what steps do I take to have that value cleared out when the form is set to a different status?