I wanna call script include value and set in business rule of custom field value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2024 10:26 AM - edited 10-28-2024 07:43 PM
scriptincludefunction: function(current) {
I wanna checking value to set on the business rule field that is list
In Business rule syntax:-
var x = new scriptincludename();
Please help me to how to write syntax on BR to get value from script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2024 08:12 PM
Hi @Anish9515 ,
You need to add a return statement.
scriptincludefunction: function(current) {
var groupId = gs.getProperty("group_user");
var test = new GlideRecord("sys_user_grmember");
test.addEncodedQuery("group=" + groupId);
test.query();
while (test.next()) {
if (field1.indexOf(test.user.toString()) == -1 && field2.user.toString().indexOf(requester) == -1) {
if (checking) {
checking += ',' + test.user.toString();
} else {
checking = test.user.toString();
}
}
}
return checking;
}
And write the business rule, with conditions Before Insert/Update.
u_field_name = new scriptincludename().scriptIncludefunction();
If the above information 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
10-29-2024 10:47 AM
@Najmuddin Mohd
Using logs I have noticed , checking has sysid's , How to return those sysyid in script include
My custom field type is "LIST" , How to set those sysid
your syntax is working but how to set those sysid
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2024 08:51 PM
Hi @Anish9515
It looks like there might be a few points of confusion in your script. Here are some areas to review:
- The parameter current is defined but never used in the function.
- Variables field1 and field2 are called, but it’s unclear where they’re defined.
- The requester variable also appears to be missing a definition.
- There's no checking variable defined before it's used
Could you provide more details on what you’re aiming to accomplish with this code? It’ll help us offer more precise guidance.
Cheers,
Tai Vu