How to get previous record details

nagaklv
Tera Contributor

Hello Community,

we have custom UI action in custom application "Copy Required Fields" and if we click the UI action we want redirect to new record and need to copy previous values to new record and it's should not save and we already aware we placed the logic in Script include and send the information to client side through on click function.

We are looking the way how to send previous record to server side so that  we will add remaining logic to pull and populate required field details in new record

and also once we click the UI action it' should be redirected new record in same window without saving

 

It would be great help if anyone provide guidance for this.

 

Thanks,

Nagesh

4 REPLIES 4

Ankur Swami
Tera Guru

Hi,

Try adding below script in your UI Action and modify field names according to your requirement.

 

var newRec = new GlideRecord(current.getTableName());

newRec.newRecord();

newRec.short_description = current.short_description;

newRec.description = current.description;

newRec.update();

action.setRedirectURL(newRec);

 

And below is the example of Copying current record without Insert().

 

Copy Record

Thanks for the response ankur and we are looking the way to place the logic in client &server side.In future we will get request to add more fields to copy in new record.

 

Thanks,

Nagesh

Hi,

 

For that may be you can make some custom logic like "Copy Change" functionality.

For that there is a property where whatever the fields are required to be copied can be put, And whatever the fields are present in the property gets copied for the "Copy Change" functionality. May be you can refer the OOTB Copy Change functionality and build your custom solution like that.

Something like below image:

 

You can make you custom property and put the attributes of your custom table from where you want to copy.

Now Glide the property where you will check what fields you have to copy and pass them to you copy code instead of hardcoded fields.

By using this if in future you need to add some more fields then you can add them in the property instead of modifying the code.

 

Please mark correct if it helps you to build your logic.

 

find_real_file.png