
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2019 10:14 AM
Hi,
I am trying to get a column value from a table which I created, u_my_usertable, in SN workflow script task.
I am new to SN & scripting, I may be doing silly mistake.
u_fileid is a column in my u_my_usertable table.
Here is my code.
var wfname = workflow.name();
var gr = new GlideRecord('u_my_usertable');
gr.addQuery('sys_id',current.sys_id);
gr.query();
var fileid = gr.getDisplayvalue('u_fileid');
var loggedMessage = workflow.info(wfname + " WF has started with FileId = " + gr.getDisplayvalue('u_fileid') + " , SecondTry = " + fileid );
my Output
undefinedWF has started with FileId = , SecondTry= null
Can someone please help ?
Thanks,
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2019 11:02 AM
I changed the code like below and it is working now, but still workflow.name() is not working for me so I changed my requirement.
I don't know why I was making my code complicated earlier. learning through mistakes :-). Thanks for your help.
var loggedMessage = workflow.info("Workflow instance " +current.sys_id + " has started with FileId " + current.u_fileid );
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2019 10:17 AM
var wfname = workflow.name();
var gr = new GlideRecord('u_my_usertable');
gr.addQuery('sys_id',current.sys_id);
gr.query();
if(gr.next()){
var fileid = gr.getDisplayvalue('u_fileid');
var loggedMessage = workflow.info(wfname + " WF has started with FileId = " + gr.getDisplayvalue('u_fileid') + " , SecondTry = " + fileid );
}
Please mark my response as correct and helpful if it helped solved your question.
-Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2019 10:22 AM
Hi,
Can you confirm for below as this is something where the issues is lying.
gr.addQuery('sys_id',current.sys_id);
what is the current table? Also, make sure getDisplayvalue() is getDisplayValue()
Thanks,
Jaspal Singh
Hit Helpful or Correct on the impact of response.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2019 11:02 AM
I changed the code like below and it is working now, but still workflow.name() is not working for me so I changed my requirement.
I don't know why I was making my code complicated earlier. learning through mistakes :-). Thanks for your help.
var loggedMessage = workflow.info("Workflow instance " +current.sys_id + " has started with FileId " + current.u_fileid );

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2019 11:08 AM