insert and delete a record from one table to another table

Kishore8
Kilo Guru

i have created 2 tables 1.sales_lead

                                                                        2.u_dupl_lead

i have created one checkbox in "sales_lead", when i check this checkbox, automatically record should delete from "sales_lead"     and insert into "u_dup_lead".

but here problem is record was inserted into " u_dup_lead" but   not deleted from " sales_lead".........

Here is my script.

Table: "sales_lead"

AFTER,                 INSERT, UPDATED.

SCRIPT:

if(current.u_archive_now==1)

{

var gtt=new GlideRecord("u_duplicate_leads");

gs.addInfoMessage("inserting...");

gtt.u_dup_archive=current.u_archive_now;

gtt.first_name=current.first_name;

gtt.last_name=current.last_name;

gtt.account_name=current.account_name;

gtt.assigned_to=current.assigned_to;

gtt.insert();

var go=new GlideRecord("sales_lead");

go.addQuery('sys_id',current.sys_id);

go.query();

if(go.next())

{

gs.addInfoMessage("deleteing");

go.deleteRecord();

}

}

7 REPLIES 7

Hi Kishore,



on Sales Lead table create   Business Rule and insert this code



so what you do is in advanced tab give condition like this



On After : Update  



CONDITION :   current.u_archive_now==1



current.deleteRecord();   // deleting current record.


// Inserting record:


var gtt=new GlideRecord("u_duplicate_leads");


gs.addInfoMessage("inserting...");


gtt.u_dup_archive=current.u_archive_now;


gtt.first_name=current.first_name;


gtt.last_name=current.last_name;


gtt.account_name=current.account_name;


gtt.assigned_to=current.assigned_to;


gtt.insert();




Thanks


Hi,



Record are deleted , but deleted record are created in Sales_lead and u_dup_lead.....



i have to create on side only...


once record will be deleted   from "sales_lead" that deleted record should created in only "u_dup_lead", but here that deleted record created in 2 -sides, in "sales_lead"   and "u_dup_lead"


harishdasari
Tera Guru

Hi Kishore,



are you able to resolve your issue ?




Thanks