The CreatorCon Call for Content is officially open! Get started here.

Issue with "onAfter" script with in transform map.

kamal11
Giga Expert

Hi All,

We are facing an issue with the onafter script that we use in transform.

we are trying to bulk update the Records and we want the records which have been updated to update "work-notes" as well.

We have used the following code

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

if(action == "update")

target.u_work_notes = "The Ordered fields of the asset have been updated as per STRY##";

gs.log('The asset with the following serial number is updated: ' + target.serial_number);

})(source, map, log, target);

How ever

it isnt updating the record worknotes

Please let us know if we have to correct something on the same.

Thank you,

Kamal

22 REPLIES 22

divya mishra
Tera Guru

Hey Kamal,



Could you try the below code   :



(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {




if(action == "update")


target.work_notes = "The Ordered fields of the asset have been updated as per STRY##";


gs.log('The asset with the following serial number is updated: ' + target.serial_number);



})(source, map, log, target);






post me your feedback



Please Hit ✅Correct, ��Helpful, or ��Like depending on the impact of the response



Have a lovely day ahead




Regards,



Divya Mishra


Hi Divya,



Have tried it but no it made no difference.



The field 'work notes' which we are trying to update through on after field script is a journal field.



The strange thing is that it is updating all (irrespective of the record update) records if we put the same script in on before field script. But the condition is that we only need to update the work notes of the records which are updated through transform map.



please suggest as it is customer critical.



Thanks.


rajmasurkar
Giga Guru

Hi Kamal,



Can you place a log statement inside function and check whether it is getting called or not?



Raj


divya mishra
Tera Guru

Hey Kamal,



Got the reason why:



The onAfter event script is processed at the end of a row transformation, after the source row has been transformed into the target row and saved. Here the record is already saved into the system and has no more access to its field anymore for that particular record.





post me your feedback


Please Hit ✅Correct, ��Helpful, or ��Like depending on the impact of the response


Have a lovely day ahead




Regards,


Divya Mishra


Hi Divya,



How can we get a solution to update the asset records??



thanks,


kamal