gives unique id with java script function

225 views
Skip to first unread message

ingen...@bammtech.cl

unread,
Mar 19, 2015, 12:17:05 PM3/19/15
to suppor...@runmyprocess.com
I want to make a java script that gives to all the rows with pattern "HW" different unique id like in the function

function update_ok(result) {
alert("ok " + JSON.stringify(result));
}

function uniqueId(){
var idstr=String.fromCharCode(Math.floor((Math.random()*25)+65));
do {
// between numbers and characters (48 is 0 and 90 is Z (42-48 = 90)
var ascicode=Math.floor((Math.random()*42)+48);
if (ascicode<58 || ascicode>64){
// exclude all chars between : (58) and @ (64)
idstr+=String.fromCharCode(ascicode);
}
} while (idstr.length<32);

return (idstr);
}

function update_ko(result) {
alert("ko " + JSON.stringify(result));
}

var my_pattern = {};
my_pattern.TYPE = "HW";

var my_object = {};
my_object.codigo = "444-555";
my_object.codigo = uniqueId();

col_paloalto2.updateMultiCallback(my_pattern,{$set:my_object},update_ok,update_ko);


with this code a give the same unique id to all the rows in HW pattern. I know that my option is use the for loop, and update it back in for loop, but I can not think how to modify the script to include the loop. Can you help me with that plese?

Bidisha Das

unread,
Mar 19, 2015, 1:23:18 PM3/19/15
to suppor...@runmyprocess.com
Hi,
Please refer to it and let me know in case you face any issue.


Thanks & Regards
Bidisha

Grupo Ingenieria

unread,
Mar 19, 2015, 1:26:34 PM3/19/15
to suppor...@runmyprocess.com
I can not see anything

Imágenes integradas 1

--
Fujitsu - RunMyProcess
---
You received this message because you are subscribed to a topic in the Google Groups "Fujitsu RunMyProcess Developer Community" group.
To unsubscribe from this topic, visit https://groups.google.com/a/runmyprocess.com/d/topic/supportforum/LwLMqr8wWkQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to supportforum...@runmyprocess.com.
To post to this group, send email to suppor...@runmyprocess.com.
Visit this group at http://groups.google.com/a/runmyprocess.com/group/supportforum/.
To view this discussion on the web visit https://groups.google.com/a/runmyprocess.com/d/msgid/supportforum/CAMGV9ztCkmLk8mThpc%2Ba3yAF-zHCVyu74rQEZoqGEned8V_X5Q%40mail.gmail.com.

Bidisha Das

unread,
Mar 19, 2015, 1:27:38 PM3/19/15
to suppor...@runmyprocess.com
Hi,
I guess I sent a wrong link.

Sorry for the inconvenience.


Thanks & Regards
Bidisha Das

Grupo Ingenieria

unread,
Mar 19, 2015, 1:33:55 PM3/19/15
to suppor...@runmyprocess.com
hehehe, that is a topic that I started but after the last email I asked them to send me some screenshoots as examples in detail understand it because I was a little confused but still get no response

--
Fujitsu - RunMyProcess
---
You received this message because you are subscribed to a topic in the Google Groups "Fujitsu RunMyProcess Developer Community" group.
To unsubscribe from this topic, visit https://groups.google.com/a/runmyprocess.com/d/topic/supportforum/LwLMqr8wWkQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to supportforum...@runmyprocess.com.
To post to this group, send email to suppor...@runmyprocess.com.
Visit this group at http://groups.google.com/a/runmyprocess.com/group/supportforum/.

Sweta Suman

unread,
Mar 23, 2015, 3:29:13 AM3/23/15
to suppor...@runmyprocess.com
Hi,

I would recommended you to use free marker to update unique_id in all records of collection. In process input/output variable you can write below code to update the collection-

<#assign data = list_objects({"$query":{},"$orderby":{"name":-1}},"collection_name")>
<#assign counter = 0>
<#assign items = []>
<#list data as i>
<#assign counter = counter + 1>
<#assign myObject=P_json_accumulate( i, "unique_id", counter)>
<#assign items = items + [myObject]>
</#list>
<#assign array1 = save_object(items,"collection_name")>
${array1}

where unique_id is name of field to be added.

If you want to do using java script refer attachment. Make sure that unique_id field is present in collection.

If you still face any problem, feel free to ask.

Thanks,
Sweta


You received this message because you are subscribed to the Google Groups "Fujitsu RunMyProcess Developer Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to supportforum...@runmyprocess.com.

To post to this group, send email to suppor...@runmyprocess.com.
Visit this group at http://groups.google.com/a/runmyprocess.com/group/supportforum/.
update_script.txt

Grupo Ingenieria

unread,
Mar 25, 2015, 9:52:28 AM3/25/15
to suppor...@runmyprocess.com
you say then I do a process where the activity has as output variable the code that you sent me which adds the "unique_id" field to the collection. Then the script that is attached add to that field (unique_id) differently to the fields with "HW" pattern value. My question is, how can I do to integrate the code to sample collection backoffice I'm following?

Bidisha Das

unread,
Mar 25, 2015, 11:51:48 PM3/25/15
to suppor...@runmyprocess.com
Hi,
As you are using javascript to Add/Update/Delete collection(Backoffice), so you can refer to the js Sweta mentioned above and use it in your code. 
Else, if you want to use freemarker code, then either you need to call a Process or Composite API from your Web Interface(on Button Click).You can't use freemarker code directly in WI.It can only be used in Process or Composite API.


Thanks & Regards
Bidisha
Reply all
Reply to author
Forward
0 new messages