How we store the Record Producer Fields details in table contain field as json/script.

Kumari Divya
Giga Guru

Hi @LL

 I created 1 Record Producer on Test Case table in PDI

KumariDivya_0-1708103100080.png

Now i want to stored the Record Producer Field details-Test Case Number in table-Test Case in Field Test Result which is script type or Json when user Submitted the Record on Form.

 

KumariDivya_1-1708103423591.png

Please suggest on this  how we stored the Fields details in json format in Table.

 

Thanks in advance

Divya Kumari

8 REPLIES 8

AshishKM
Kilo Patron
Kilo Patron

Hi @Kumari Divya , 

You can prepare a JSON object for Test Number and update this field via record producer's script part.

 

Replace the test_case and test_result variables as per in your system.

 

AshishKMishra_0-1708114630569.png

Tested on Create Incident Record Producer and result as below.

 

AshishKMishra_1-1708114751527.png

 

-Thanks,

AshishKM


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Hi @AshishKM 

Could you please help me on how i get the json details from record producer in below format.

 

{"u_supplier_ship_date":[{"original_value":"abc","changed_value":" abcjdck"}]}

try the below code

 

var result ={};
var data ={};
var dataArray= [];
data.original_data = "abc"; // use producer.<fieldName> coming from catalog form
data.changed_value = "xyz"; //use producer.<fieldName> coming from catalog form
dataArray.push(data); // add data object in array

result.u_supplier_ship_date=dataArray;
current.description= new global.JSON().encode(result);

 

 Used in 'Create Incident' record producer 

AshishKMishra_0-1708521601027.png

result :

AshishKMishra_1-1708521663957.png

 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Hi @AshishKM 

Can you please help me how can i used if block inside the RP and only stored the value in Table if value changed in form.We have 2 fields on RP,if fields are updated on RP then that will store in table and if both fields are updated then both should save in Json field on table.

i tried the below code

 

var testResult= {};
if(producer.ship_date !=producer.new_ship_date){
testResult.shipDate = producer.ship_date.toString();
testResult.newShipDate =producer.new_ship_date.toString();
current.json_output =new global.JSON().encode(testResult);
}
var testResult1= {};
else if(producer.cancel !=producer.new_cancel){
testResult.cancel = producer.cancel.toString();
testResult.newCancel =producer.new_cancel.toString();
current.json_output =new global.JSON().encode(testResult1);
}

Thanks in advance

Divya