How to populate company value from user table on incident form automatically ?

Ujjwala1
Tera Contributor

Hello Experts,

I have created a transform map which is linked to the import set table, in the run as script section I have written code to populate some fields at the time of ticket creation except company, script is taking every other field value,

Since I am working in MSP env, the script is automatically taking random field value for the company field which is a dot walked field from the user table, Could anyone suggest to me how should I fix that up?

Table Transform map: Data upload for tickets

Target table: Incident[incident]

run script : yes

script: 

var cafe = new GlideRecord('u_store');
cafe.addQuery('u_store_number', source.u_store_name);
cafe.addQuery('sys_domain', '');
cafe.query();
if (cafe.next()) {
    var sys_id = cafe.sys_id;
    var gr=new GlideRecord('sys_user');
    gr.addQuery('active',true);
    gr.addQuery('sys_domain','');
    gr.addQuery('company','');
    gr.query();
    if(gr.next())
        {
            
    target.company = '';
    target.sys_domain = '';
    target.u_store = sys_id;
    target.short_description = "Testing Tickets";
    target.category = "";
    target.u_type = "";
    target.u_item = "";
    target.assignment_group = "";
    target.contact_type = "email";

}
}

Any kind of help here is much much appreciated!

Thanks & Regards,

Ujjwala

1 ACCEPTED SOLUTION

Tony Chatfield1
Kilo Patron

Hi, can you clarify your issue, you are trying to prevent company from being populated? or it is being populated but by wrong value?
You indicate that you are running your script in the 'Run script section of the transform map?
To populate data into your target table I would move the script to a beforeTransfrom() script, so that it runs once for each row in your import, if that doesn't fix your issue then I would recommend adding some logging to confirm\validate your script functionality and the values set by the transform.

View solution in original post

6 REPLIES 6

Hi @Tony Chatfield,

the issue is company field is taking the wrong value 

actually, three things are associated with this script

I have created an inbound email and script include along with the import set table to automatically load data from an excel email attachment and should process it and based on unique ids received, it should create records on the incident table.

Inbound email action : Target table : sys_data_source

script include PFA documents for the same.

 

 

 

 

Hi, regardless of where\how you upload the files, your issue is with transform of the records in the file and the content of the file has nothing to do with the inbound action or email import script, it may be the result of the scripts but the file content is not?
I would start by moving the transform script to a beforeTransform script, this will ensure that each record is assessed\processed separately. You can then also add logging so that you can see the actual values being populated by the transform for each record.

Do you have any fields mapped or coalesced via field mapping?
Have you checked\validated them to ensure that they are not setting the domain?
Is the Transforms 'Run business rules' value true or false?