Not able to set current time to a field through script include

Abhi33
Tera Expert

Hi Everyone,

I am trying to set a field value to current date and time through script include, code as below

find_real_file.png

this is the after BR

find_real_file.png

I am getting log message as this an empty space

find_real_file.png

can anyone please let me know if there's anything wrong over here.

Thanks and Regards,

Abhi

 

1 ACCEPTED SOLUTION

Hi Tom,

Thanks for the suggestion, I made a mistake in script include 

find_real_file.png

This is working fine now

 

View solution in original post

5 REPLIES 5

Tom23
Tera Expert

Hi Abhi,

I think the problem is that you're trying to do current.sys_class_name and current.sys_id which I don't think will work in a script include. Maybe try passing the sys_id and the sys_class_name as params into your function? As an addition, you don't need to add a query or do gr.query() after a get - get fetches the record directly.

Having said that, I'm not sure what the script include is achieving that can't be completed using a standard business rule and personally I've got some doubts about using an after business rule to update the same record that's just been submitted. It seems like double processing and double submitting.

Personally I'd suggest considering a before business rule which runs this:

var time = gs.nowDateTime();

current.u_branch_down_end = time;

 

Unless I've missed something and you're actually trying to update something somewhere else?

 

Hope this helps

Hi Tom,

Thanks for the suggestion, I made a mistake in script include 

find_real_file.png

This is working fine now

 

Oh cool! Glad it's working. Good to know that you can access the current object in script includes, today I learned! 🙂

Hi Abhi,

Could you share the script of the script include that you are using to update the date and time? I have the same requirement.

Thanks.