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 :
- Criteria.
- Rating.
Assessment Form Collection has four fields:
- these are the fields that i need to copy from the "Assessment Criteria collection".
- Criteria
- Rating
- the other two fields remain blank.
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:- http://help.bizagi.com/bpmsuite/en/index.html?add_and_remove_relationships.htm
Best Regards
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:- http://help.bizagi.com/bpmsuite/en/index.html?add_and_remove_relationships.htm
Best Regards
Dear Juan Zuluaga
when I use the line :
Predefinedquestion = CEntityManager.GetEntity("Assessement.Flags.PredefinedQuestions").GetEntityList("", "", "", "");
i receive an error telling me that the entity : "Assessement.Flags.PredefinedQuestions" doesn't exist.
Regards
Dear Juan Zuluaga
the collection function category doesn't appear in the categories list, is this a new update in Bizagi Xpress?
Regards
Dear Ahmad,
Yes sr. It is one of the features of our last release (10.4). Please upgrade your Bizagi in order to obtain our last features and fixes.
Best Regards
Dear Juan Zuluaga
this is the expression that I'm using , it adds the same number of records in CollectionA (test_prededined) to CollectionB (Assessement.ICTPlans) but the fields remain blank.
Predefinedquestion = CEntityManager.GetEntity("test_prededined").GetEntityList("", "", "", "");
for( i=0; i< Predefinedquestion.Length; i++)
{
var key=Predefinedquestion.SurrogateKeyValue;
var Newrecord = Me.newCollectionItem ("Assessement.ICTPlans");
Newrecord.setXPath("Assessement.ICTPlans.EvaluationCriteria",Predefinedquestion.Criteria);
Newrecord.setXPath("Assessement.ICTPlans.EvauationRate",Predefinedquestion.Rating);
}
Regards
Dear Ahmad,
You are very close to get it. I miss something in my code and you need it. When you use Predefinedquestion in your loop, you need to add the var i of the "for" like:
var key=Predefinedquestion.SurrogateKeyValue;
That means to get value from 0 to Predefinedquestion.Length. It also apply for criteria and Rating.
you can check your values using traces. it can show what happen when your code is trying to obtain values from one collection to another: http://help.bizagi.com/bpmsuite/en/index.html?error_control_and_diagnostics_.htm
Best Regards
Dear Juan Zuluaga
Kind Regards
Dear Juan Zuluaga
In the previous comment the counter element "i" is not showing , this is the code i'm currently using, it seems that these statements :
Don't return a value , they only return undefined.
Predefinedquestion = CEntityManager.GetEntity("test_prededined").GetEntityList("", "", "", "");
for( i=0; i< Predefinedquestion.Length; i++)
{var key=Predefinedquestion.SurrogateKeyValue;
CHelper.trace("Predefinedquestion", "Key = " + key) ;
var Newrecord = Me.newCollectionItem ("Assessement.ICTPlans");Newrecord.setXPath("Assessement.ICTPlans.EvaluationCriteria",Predefinedquestion.Criteria);CHelper.trace("Predefinedquestion", "Criteria = " + Predefinedquestion.Criteria) ;Newrecord.setXPath("Assessement.ICTPlans.EvauationRate",Predefinedquestion.Rating);CHelper.trace("Predefinedquestion", "Rating = " + Predefinedquestion.Rating ) ;}
Regards
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
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
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
Comments have been locked on this page!