You should create a script rule in any place of your document definition section except for line items repeating group and its children. For example, on section level. Add the child field which instances should be populated by instance numbers into the list of participating fields of the rule and allow modification of this field by the rule. Code of the rule can be something like that ( C# ):
//===========
if ( Context.Field("fieldAlias").Items != null ) {
for ( int i = 0; i < context.field("fieldalias").items.count;="" i++="" )="">
Context.Field("fieldAlias").Items[ i ].Text = ( i + 1 ).ToString();
}
}
//===========
0
Permanently deleted user
Thank You Slowdima, the rule works. I tried before the similar code on line items rule
You are welcome Arturasv. I am glad to know that the hint was helpful.
Regarding to your initial difficulties, if rule is located within repeating document node, then program creates a separate rule instance for each exemplar of the node ( repeating group, table row, section with multiple instances etc. ) So, in this case the rule "sees" only its own exemplar, which does not have Items collection and should be accessed as a usual field. This approach can be used for writing a normalization or validation script, which should work identically for each instance and does not require access to instances collection.
コメント
3件のコメント
You should create a script rule in any place of your document definition section except for line items repeating group and its children. For example, on section level. Add the child field which instances should be populated by instance numbers into the list of participating fields of the rule and allow modification of this field by the rule. Code of the rule can be something like that ( C# ):
Regarding to your initial difficulties, if rule is located within repeating document node, then program creates a separate rule instance for each exemplar of the node ( repeating group, table row, section with multiple instances etc. ) So, in this case the rule "sees" only its own exemplar, which does not have Items collection and should be accessed as a usual field. This approach can be used for writing a normalization or validation script, which should work identically for each instance and does not require access to instances collection.
サインインしてコメントを残してください。