VMware Cloud Community
harshstar121
Contributor
Contributor
Jump to solution

vRO : Duplicate Resource Folder(category) inside another Folder.

I was just playing with vRO in my office. Let me tell you the scenario first:

So there is this workflow scheduled to run on daily basis and create 2 files in Resource Element. The requirement is to create folder inside another one and its name should be the date.

Ex. Parent folder name : Routes inside this I need to create another folder with the name like Tue Dec 10 2019 08:39:13 GMT-0000 (UTC) .

But the thing is it is creating 2 folder differently with the same name!..... 

here is the sample code i'm executing.

var location = "VM Routing Reports/abc";

System.log(location);

createFile(location);

System.sleep(2000);

createFile(location);

function createFile(location){

Server.createResourceElement(location, "hk");

}

this code is creating 2 folder with the same in in resource element.

vroissue.png

Can anyone help me to check whats wrong in code??

1 Solution

Accepted Solutions
stevedrummond
Hot Shot
Hot Shot
Jump to solution

You may need to provide different sample code then because its doing exactly as expected. Based on my understanding of your requirement I quickly wrote this which to me is doing exactly what you want.

scheduledRun();

System.debug('Sleeping 5 seconds');

System.sleep(5 * 1000);

scheduledRun();

function scheduledRun() {

    const rootPath = 'drummo';

    const resourceElement = Server.createResourceElement(rootPath + '/' + new Date().toISOString(), 'my_element');

    System.debug(resourceElement.name);

}

pastedImage_0.png

View solution in original post

5 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

Which vRO version is this? I wasn't able to reproduce this behavior on one of the my deployments I have at hand (vRO 7.3).

0 Kudos
stevedrummond
Hot Shot
Hot Shot
Jump to solution

I'm confused. It's doing exactly what your code is telling it to.

You have statically defined the path as var location = "VM Routing Reports/abc"; . You then create a Resource Element at that path called hk.

Your problem statement mentioned you wanted the folder to be named by the date? Shouldn't you then be calling:

createFile(<location>, <name>) where name is your timestamp style name? And then your call is Server.createResourceElement(location, name)?

0 Kudos
harshstar121
Contributor
Contributor
Jump to solution

Hi

I'm using vro 7.5

0 Kudos
harshstar121
Contributor
Contributor
Jump to solution

Hi

actually the date style name is my actual scenario(actual project work bit complex). It was not working in that so I tried with simple few line code to create 2 files in the same location (assume abc inside VM Routing Reports also assume abc folder is not present initially).

0 Kudos
stevedrummond
Hot Shot
Hot Shot
Jump to solution

You may need to provide different sample code then because its doing exactly as expected. Based on my understanding of your requirement I quickly wrote this which to me is doing exactly what you want.

scheduledRun();

System.debug('Sleeping 5 seconds');

System.sleep(5 * 1000);

scheduledRun();

function scheduledRun() {

    const rootPath = 'drummo';

    const resourceElement = Server.createResourceElement(rootPath + '/' + new Date().toISOString(), 'my_element');

    System.debug(resourceElement.name);

}

pastedImage_0.png