Can a string field from source file mapped to the Currency type filed on the target record ?

SAS21
Tera Guru

fields on the target record is

  1. 'Amount spent $'  - currency type field. 
  2. 'vendor id' - string type

source file column

  •   'Amount spent' - string type.

existing logic is  -  based on the vendor id, populating vendor information like address, contact no ,email, Amount spent etc

Run Business rules is checked in the transform map and there is a before insert update Br that auto populates the above vendor information. I just wrote the below lines, in on before transform script. Just giving the vendor Id and rest of the details are populating on the inserted record except 'Amount spent'

 

Requirement is if 'Amount spent' from the source file is empty then it should populate from 'vendor id'  else the Amount spent should have the value from source file.

 
Onbefore script:
 if (!gs.nil(source.u_vendor_id)) {
            gr.x_cyc_vendor_id = source.u_vendor_id;
        }

 

onafter script: 

if (!gs.nil(source.u_amount_spent)) {
                gr.x_cyc_u_amount_spent = source.u_amount_spent;
            }
 
the issue is auto population is not happening for Amount spent field from the 'vendor id' .  Please suggest
 
2 REPLIES 2

KrishnaS8631098
Tera Contributor

Hello @SAS21 

 

Please try to add currency type. 

 gr.x_cyc_u_amount_spent = 'USD;' +source.u_amount_spent;

 

Regards,

Krishna Sharma

Ankur Bawiskar
Tera Patron
Tera Patron

@SAS21 

the auto population is happening from before insert BR.

you are using gr object to create record on target table?

share complete onBefore & onAfter transform script.

In your onAfter use this

if (!gs.nil(source.u_amount_spent)) {
gr.x_cyc_u_amount_spent = source.u_amount_spent;

gr.update();
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader