How can I copy a specific object present in a list using the copy task?

Here is the scenario.
I have a list called submitted.
image
Now I want to copy any object, suppose I want to copy 1st index object.


How can I achieve this?

8 Likes

Hi @Neeraj_Kumar ,

Thanks for raising the question.

Currently, there is a limitation in vDesigner regarding native paths—you cannot directly pick and copy a specific object using a path. However, there is a workaround for this. You can achieve it by creating a JavaScript function that extracts the desired object. Here’s an example:

function getItemByIndexStringified(list, index) {
// Validate the input to ensure it’s a valid list and index

if (index < 0 || index >= list.length) {
console.error(“Index out of bounds.”);
return null;
}

// Retrieve and stringify the item
return JSON.stringify(list[index]);
}

Steps to Implement in vDesigner:

  1. Create the JavaScript Function:
  • Add this function in the JS Editor within vDesigner.
  1. Use invokeFunction Task:
  • Configure an invokeFunction task to call this JavaScript function.
  • Pass the list and the index as inputs to the function.
  1. Copy Output Using outputLocation:
  • Use the outputLocation property to store the function’s output and consume it wherever needed.

connect with @Ritik_Dixit for further help.

3 Likes