the importance of inc.autoSysFields(false); & inc.setWorkflow(false);

sonbol_montakha
Giga Contributor

Why is it important to have   these two on business rules?

inc.autoSysFields(false);   &

inc.setWorkflow(false);

I noticed I will loose my activity log ( work_notes) filed for instance and i need that.

The question is? are they really necessary ?

the BR is running on [sys_user] table.

thanks

4 REPLIES 4

ghsrikanth
Tera Guru

The line-


inc.autoSysFields(false); - disable the update on sys_updated_on, sys_updated_by, sys_mod_count etc.


This is primarily used, if through script if you dont want to keep track of who has updated the record


GlideRecord - ServiceNow Wiki


Section 10.1 autoSysFields



inc.setWorkflow(false); - this will prevent all Business rules from firing, if you want to make an update on the table but you dont want any business rule to fire up


GlideRecord - ServiceNow Wiki


Section 10.2 setWorkflow



then the above lines are used, primarily this line is used along with


After business rule


And that business rule has the script current.update();


Most probably the business rules which are using these lines doesn't want either tracking or firing of business rules.



Mark if it is correct or helpful, feedback is appreciated





Thank you so much for ur response. actually my BR is on before! so do you think I can remove these lines from my script?I really need the activity log to be shown!


Usually its not advised to use these lines until unless your design needs it.


For ex: In fixing some data in the table, we end up writing a fix script, in that we wont be needing to trigger business rules or capture the update in the history.


In these cases we regularly use these lines.



If your design doesnt demand these requirements then you can remove them.


Thank you so much! I don't think my design needs them as I'm just removing inactive people from their assigned tasks.