Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Clone Functionality

Shusovit Dutta
Tera Contributor

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 G- LNG
Tera Patron
Tera Patron

Hi @Shusovit Dutta 

 

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

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

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();
}

 

 

By marking my response as correct or helpful, you contribute to helping future readers with similar issues.
Regards,
Abhijit
ServiceNow MVP