Copy the Field from the task table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2024 01:41 PM
Hi folks,
Please find the below screenshot
Now My reequrement is if the time card is being inserted and Category Is Task_work then cost center field should be automatically updated to cost center value on the task record,(Cost Center is the reference field on both the tables).
For this Purpose I created a BR as following but itsnt working.
with following script.
But it's not working, can anyone gimme some pointers please.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2024 05:48 AM - edited 03-26-2024 10:05 AM
Can you please look into The above scenario where I wrote an after insert/Update BR on task table.
Table- Task
When to Run
AFTER - Update
cost center is not empty
Advanced
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2024 09:41 PM
Hi @Sam Hanson
Let's give my adjustment below a try.
(function executeRule(current, previous /*null when async*/ ) {
var grTask = current.task_work.getRefRecord();
if(grTask.isValidRecord()){
current.u_cost_center = grTask.getValue('u_cost_center');
}
})(current, previous);
And also try to avoid using update() inside a business rule.
Prevent Recursive Business Rules
Do not use current.update() in a Business Rule script. The update() method triggers Business Rules to run on the same table for insert and update operations, potentially leading to a Business Rule calling itself over and over.
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2024 08:01 AM
I tried your script too but its doing exactly the same. Cost center is being populated on after I save the record(time_card). It has to update the cost center while creating itself.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2024 10:40 AM
If you want this to be shown on the form as soon as you select the task than you should use a combination of Client Script onChange for Task field with a GlideAjax call to a client callable script include.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2024 06:56 AM
For now this gives me what is needed but I want cost_center on the time card to be inserted when people inserts the cost_center field on any records in the task table too.
So, I proceeded and wrote another BR on the task table.
Table- Task
When to Run
AFTER - Update
cost center is not empty
Advanced