- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2023 03:43 AM
Hello, just need some scripting help.
I've created a custom table to store "personas" and each one has a department assigned.
What I'm trying to achieve is if the department on the u_personas table matches the department on the user profile it will update the record with matching persona in field u_persona.
(function executeRule(current, previous /*null when async*/ ) {
var persona = new GlideRecord("u_persona");
persona.addQuery("department", current.getDisplayValue("department"));
persona.query();
while (persona.next());
if (persona.department == current.getDisplayValue("department")) {
current.u_software == persona.sys_id;
}
})(current, previous);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2023 05:20 AM
Sorted it in the end...
var persona = new GlideRecord("u_persona");
var department = current.getDisplayValue('department');
persona.addEncodedQuery("department", department);
persona.query();
if (persona.next()) {
current.u_software = persona.sys_id;
persona.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2023 05:07 AM
Hi its running on the sys_user table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2023 05:20 AM
Sorted it in the end...
var persona = new GlideRecord("u_persona");
var department = current.getDisplayValue('department');
persona.addEncodedQuery("department", department);
persona.query();
if (persona.next()) {
current.u_software = persona.sys_id;
persona.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2023 05:47 AM
Hello @Andrew_TND
persona.addEncodedQuery("department" , department);
Is worked ...??
its should be like this know...As you are using "addEncodedQuery"
persona.addEncodedQuery("department=" + department);
OR
persona.addQuery("department",department);
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates