- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2017 01:24 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2017 02:24 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2017 01:47 AM
Hi Padhu,
You may write Business rule as per sample script as below. Define the Business rule when to run.
var img_value = current.img_data_field_name;
var id = current.reg_id;
var field1 = current.field_1_name; //fetch the value of 1st field name which will be compared with the 2nd field in 2nd table.
var gr= new GlideRecord('2nd_table_name');
gr.addQuery('reg_id', id);
gr.addQuery('field_2_name', '!=', field1);
gr.queary();
if (gr.next()) {
gr.fiield_2_name = field1;
gr.update();
}
I hope this helps.Please mark correct/helpful based on impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2017 02:24 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2017 02:30 AM
Hi Padhu,
If your requirement is to copy all the fields value from a section then mention the field name one by one inside the if() loop as:
if (gr.next()) {
gr.fiield_2_name = field1;
gr.new_field_name1 = current.source_field_name1;
gr.new_field_name2 = current.source_field_name2;
gr.new_field_name3 = current.source_field_name3;
gr.update();
}
I hope this helps.Please mark correct/helpful based on impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2017 09:54 PM
Hi Amlan Pal,
until this code working fine .below line of code is not working.can u please review this?
gr.fiield_2_name = field1;
gr.update();
Thanks in Advance.