- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2023 10:26 PM - edited 10-23-2023 10:31 PM
problem:
importする際にassigned_toの参照していないユーザーも挿入できるような状態になっている。
reference:
sys_userの中で以下の条件で当てはまったuserである。
rolls=itil^ORroles=a.user^ORroles=b.user^EQ
試したコード:
ソーススクリプトでproblemを解決するために作成したコードは以下である。
結果は、どのユーザーでもrejectされskipする
answer = (function transformEntry(source) {
var table = new GlideRecord('sys_user');
table.addEncodedQuery('rolls=itil^ORroles=a.user^ORroles=b.user^EQ');
table.query();
if (table.next()) {
return source.u_assigned_to;
}
})(source
分かる方がいたら教えてほしいです。
お願い致します。
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2023 11:33 PM
@izanacart111 why are you returning assigned_to, I think you should return variable table.
answer = (function transformEntry(source) {
var table = source.u_assigned_to;
if(table){
var userRoles = new GlideRecord('sys_user');
userRoles.addEncodedQuery('rolesINitil,a.user,b.user^sys_id='+table);
userRoles.query();
if (userRoles.next()) {
return table;
}
}
})(source);
Best regards
Suyog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2023 10:34 PM
Hi @izanacart111,
Try below script
answer = (function transformEntry(source) {
var assignTo = source.u_assign_to;
if (assignTo) {
var userRoles = new GlideRecord('sys_user');
userRoles.addEncodedQuery('rolesINitil,a.user,b.user^sys_id=' + assignTo);
userRoles.query();
if (userRoles.next()) {
return assignTo;
}
}
})(source);
Thanks,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2023 11:14 PM
dear Anand Kumar P
まずはアドバイスありがとう。
実際にAnandのコードを試してみた。
コード以下である
answer = (function transformEntry(source) {
var table = source.u_assigned_to;
if(table){
var userRoles = new GlideRecord('sys_user');
userRoles.addEncodedQuery('rolesINitil,a.user,b.user^sys_id='+table);
userRoles.query();
if (userRoles.next()) {
return assigned_to;
}
}
})(source);
結果は、スキップになってしまった。
エラーメッセージは以下である
Reference field value for task.assigned_to rejected: undefined
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2023 11:33 PM
@izanacart111 why are you returning assigned_to, I think you should return variable table.
answer = (function transformEntry(source) {
var table = source.u_assigned_to;
if(table){
var userRoles = new GlideRecord('sys_user');
userRoles.addEncodedQuery('rolesINitil,a.user,b.user^sys_id='+table);
userRoles.query();
if (userRoles.next()) {
return table;
}
}
})(source);
Best regards
Suyog