How can I skip updating a field on an import when action == update?

tt-jtw
Kilo Expert

I have a Transform Map that uses change_request as its target table.

 

When the action on an import row is to "insert", I'd like to fill in the Requested by field.

But if the action is "update" (revising an existing Change Request), I'd like to skip updating that field.

 

How do I do this?

 

I was hoping I could evaluate the action variable inside a field map script, but it does not seem to be the case.  

7 REPLIES 7

Mike Allen
Mega Sage

Does that field change?   It will skip it unless the field changes.



Maybe you could use a source script.   Something like:



if(action == insert()){


answer = source.requested_by;


}


else{


ignore = true;


}



Or something like that.


Or, that is exactly what you meant by evaluating action.   Let me think more on this.


What about an onAfter transform script that says



if (action = insert()){


    source.requested_by = target.requested_by;


    target.update();


}



Or maybe an onBefore and you won't need the update?


I cannot use onAfter because that is after the target record is saved.   I cannot use onBefore because I do want some fields to update, but not others (on update).



At the moment, I'm pulling those fields out of the field map and setting them in the Transform Map's Run Script.   I was hoping there was a simpler way.