Clone Functionality

Shusovit Dutta
Tera Expert

Want to have a clone UI action kind of functionality where I will ask few field values in a UI page, and apart from those field values I want to copy the rest of the fields as it is.

I want to know how can I write a gliderecord query that will take in few fields as a user input and rest will be a copy from the current record.

2 REPLIES 2

Dr Atul - LNG
Tera Patron

Hi @Shusovit Dutta 

 

Could you please provide more details, what is your use case. 

Abhijit4
Mega Sage

You can use below script to copy all data from one record to another and override ui page fields as I mentioned in script.

 

Note : I have created example for incident, you can change table name based on your requirement.

 

 

var current=new GlideRecord("incident");
if(current.get("9e7f9864532023004247ddeeff7b121f")){
var grIncident=new GlideRecord("incident");
grIncident.initialise();

//Copu current record data to new record
for (var data in current){
grIncident[data]=current[data];
}
grIncident["ui_page_field_1"]="test 1";
grIncident["ui_page_field_2"]="test 2";
grIncident.insert();
}