Answered

How can I copy data from on collection to another?

I'm trying to copy values from one collection to another.

for example :

Assessment Criteria collection has two fields :

  1. Criteria.
  2. Rating.

Assessment Form Collection has four fields:

  • these are the fields that i need to copy from the "Assessment Criteria collection".

  1. Criteria
  2. Rating

  • the other two fields remain blank.

Best Answer
photo

Dear Ahmad,

In order to copy values from one collection to another, please create a script with these characteristics:

Create a first loop to get values. You can access to those registers. An example is of it:

EntTableList= CEntityManager.GetEntity("CollectionA").GetEntityList("", "", "", "");

for(i=0; i< EntTableList.Length; i++)

{

//obtain the primary key of the register

var key=EntTableList.SurrogateKeyValue;

// Rest of the script

}Then, into of this loop (Rest of the script), add registers to the new collection. You can use newCollection function:

Best Regards

photo
0

Dear Ahmad,

Yes, on this forum, we cannot use [ i ]. ( "i"). Please try removing .GetEntityList("", "", "", "") from the fuction.

Another way is with the iterate Over Xpath fuction: http://wiki.bizagi.com/en/index.php?title=Iterate_over_Fact_or_XPath#Iterate_over_XPath_example

Best Regards

photo
0

Dear Juan Zuluaga,

I'm using iterate over xpath with "Predefinedquestion" as an object variable, the copying process seems to work but i'm receiving wrong output.

this is the code :

criteria =Predefinedquestion.getXPath("Criteria");

rating = Predefinedquestion.getXPath("Rating");

var Newrecord = Me.newCollectionItem("Assessement.ICTPlans");

Newrecord.setXPath("Assessement.ICTPlans.EvaluationCriteria",criteria);

CHelper.trace("Predefinedquestion", "Criteria = " + criteria);

Newrecord.setXPath("Assessement.ICTPlans.EvauationRate",rating);

CHelper.trace("Predefinedquestion", "Rating = " + rating) ;

I'm copying two rows of data from one collection to another, the trace file shows that the rows are in the correct order but the results i'm receiving in the work portal show the opposite. it assigns the values in the last record to all the values in the collection.I've attached the trace file and a screen shot of the work portal

Regards

photo
0

Dear Ahmad,

you will find all the information you need in the following link

http://help.bizagi.com/bpmsuite/en/index.html?add_and_remove_relationships.htm

Also try to put just the name of the column of the record you are going to add, so it would be like this

Newrecord.setXPath("EvaluationCriteria",criteria);

And that should work.

Regards