You are viewing limited content. For full access, please sign in.

Question

Question

Workflow SDK Script - Get Dynamic Field ID List - ILFCollection Error

asked on October 10, 2014

I'm trying to grab a list of the Field IDs for all fields in a template that have dynamic field rules. The idea is to maintain a C# list of all the IDs so I can reference them quickly later on without having to search through all the form logic rules each time. Based on the SDK documentation, I've been able to get the following code:

List<long> dFieldIDs = new List<long>();
bool hasDynamicFields=false;

if(lfTemplate.HasFormLogicRules){
    hasDynamicFields=true;
    ILFCollection dynFields = (ILFCollection)lfTemplate.GetAllFieldFormLogicRules();
    foreach(LFFormLogicRule dField in dynFields){
        dFieldIDs.Add(dField.TemplateFieldID);
    }
}

I get an error with the portion of the code trying to cast the GetAllFieldFormLogicRules() result to ILFCollection:

 

I've checked the references for the script, and it seems to be OK (removed RepositoryAccess, added LFSO90Lib). Has anyone seen this before?

0 0

Answer

SELECTED ANSWER
replied on October 10, 2014

Between LFSO83 and LFSO90, LFTemplate.GetAllFieldFormLogicRules was changed to return an LFFormLogicRuleCollection instead of an LFCollection. Sorry for the ambiguous sample code. I will update the samples in the documentation to reflect this change.

0 0
replied on October 10, 2014

Thanks, that fixed the issue. Although the new class doesn't implement any enumerators, so you can no longer use "foreach." Had to modify the code to use a 1-based for loop:

if(lfTemplate.HasFormLogicRules){
    hasDynamicFields=true;
    LFFormLogicRuleCollection dynFields = lfTemplate.GetAllFieldFormLogicRules();
    LFFormLogicRule dField;
    for(int i=1;i<=dynFields.Count;i++){
        dField = dynFields.GetRule(i);
        dFieldIDs.Add(dField.TemplateFieldID);
    }
}

 

1 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.