Script help to set choice list

Service Manager
Kilo Guru

Hi All,

 

We are importing the records into a custom table but we would like to set the value of choice list filed "status" to closed only when we import state as closed. I tried with onchange /onload client script but it didn't work.

 

Thanks

8 REPLIES 8

Do you have it set up on your PDI instance so that I can take a look?

 

-Pradeep Sharma

I've PDI instance but this functionality don't exits 
I can explain you in briefly

we have 5-6 options for status field on custom field

and similarly for state field 3-4 options

when we import the data we have same choice list "0" which must display two different options in same field(status) 

we need to differentiate based on another field (state)

like when status is work in progress then state is work in progress 

and when status is closed then we want state to be closed.

but the value we import is same for state and based on status we need to change it to closed

 

Thanks

Did you update it in the script section of field map "State"? If yes then the below script should work unless you have some server-side script aborting the update.

if(source.u_status == '0')
	{
		answer = '3';
	}
else
	{
		answer = '2';
	}

The above script I added as the source script of state field(state) on Transform map

and tried below script but the values on status field showing as undefined

 

answer = (function transformEntry(source) {

    // Add your code here
if(source.u_status == '0')
    {
        answer = '7';
    }
else
    {
        answer = '1'|| '5'||'0'||'2'||'3'||'4'||'6';// field choice list values, I tired with one choice or multiple but the issue is remains same as undefined
    }

})(source);

 

Thanks