- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2023 11:23 PM
Hello All,
I need to fetch sctask number from the email body and I need to update the record.
please help me with the script.
example number: SCTASK1234567.
Thanks.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2023 11:43 PM
Hello,
Below is example of fetching number from Subject, you can replicate for body as well.
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2023 04:45 AM - edited 10-27-2023 04:52 AM
@Musab Rasheed, @Ankur Bawiskar
The above link helped me in fetching the task number.
but am unable to update the reference field from the script.
(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
var subject = email.subject.toString();
var regex = new SNC.Regex('/SCTASK\\d{7}/im');
var match = regex.match(subject);
var task = new GlideRecord('sc_task');
task.addQuery('number',match);
task.query();
while(task.next())
{
task.work_notes = 'email.body';
task.u_digilocker.u_locker_status = 2;
task.update();
}
})(current, event, email, logger, classifier);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2023 05:07 AM
Which is reference field here ? generally you should pass sys id as reference field value but I don't see it here
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2023 05:35 AM
can you provide me the sample syntax please.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2023 06:36 AM - edited 10-27-2023 06:36 AM
like
task.assigned_to = "sys id of user";
Like this
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2023 12:56 AM
Hello @Ankur Bawiskar @Musab Rasheed
As per the above requirement i written below script. First part is working fine (gliding to task table and updating the worknotes)
But second part is not working (unable to update the stockroom table).
can you please and help me.
var task = new GlideRecord('sc_task');
task.addQuery('number',match);
task.query();
while(task.next())
{
var status = task.getValue('u_digilocker');
gs.info('namee: '+ status);
task.work_notes = email.body_text();
task.state = 2;
task.update();
var st = new GlideRecord('alm_stockroom');
st.addQuery('name',status);
gs.info('abcd' + status);
st.query();
while(st.next()){
st.u_locker_status = 2;
st.update();