how to compare 2 different fields on 2 different tables after comparing data is not same copy the data into table1 differet section.

padhu1
Kilo Expert

I have Table1 and table 2 :

                                                                          I need to compare 2 different fields on 2 different tables and   we have common id field on 2 tables like(reg id) and

(if img data !=sdpe data, copy the "img data"(section in table1) to "upd   data"(another section in table1)

Note:img data is (table1 field),   sdpe is (table2 field).

any one give the sample code for this req.

is this clear.if not please comment it.

Thanks in Advance.

Message was edited by: padhu1 padhu1

1 ACCEPTED SOLUTION


Amlan pal,


                                        Thanks for the quick reply.


how will pass the section name here? once


(if img data !=sdpe data,copy the "img data"(section in table1) to "upd   data"(another section in table1).how to copy the data?




View solution in original post

7 REPLIES 7

Hi Padhu,



Please use as below:


gr.new_field2_name = current.source_field_name;



You can use simply field1 if you have already defined any variable named that and stored the value of the source field value inside the variable. In my earlier example I have defined the variable named field1, you may have a look at that.



I hope this helps.Please mark correct/helpful based on impact


I have similar requirement, but i dont have common field in two tables.

My requirement is custom table "cmdbtest" with field name "Name"

and cmdb_ci table with field name "Name"

 

I need to compare Name of cmdbtest and cmdb_ci table. whichever data do not match , I need to populate report for that unmatched data

nayanawadhiya1
Kilo Sage

Hey padhu1,




You can GLIDE the record from the second table and compare with the first table record if it doesn't match then you can copy the data into first table.


Refer this for GLIDERECORD-


Using GlideRecord to Query Tables - ServiceNow Wiki