Expression Error - Invalid index

Hi All, I'm getting the following error:

Error Evaluating UI Expression Expression evaluation error in rule 'ctm_reviewissuesform' at function a!formLayout_17r1 [line 16]: Invalid index: Cannot index property 'protocolNum' of type Text into type List of Variant

Note the below code snippet does not match the line numbers mentioned in this error, I just took a piece of the code to display here. The error [line 16] refers to [line 5] below--

The scenario is that I've edited the Label of one Interface to the following: 

  a!formLayout_17r1(
    label: if(
      condition: isnull(ri!step), 
      valueIfTrue: "Review Monitoring Form Issues for " & 
        rule!CTM_getStudyProfileInfoById(ri!CTM_MONITORING_EVENT.studyProfileID).data.protocolNum & 
        " (ID: "& ri!CTM_MONITORING_EVENT.eventID & ")",
      valueIfFalse: choose(ri!step,
         "Set Resolution Due Dates & Send Initial Summary to Study Team for "&
         rule!CTM_getStudyProfileInfoById(ri!CTM_MONITORING_EVENT.studyProfileID).data.protocolNum
         & " | " & rule!CTM_getRefDataLabelById(local!site.siteName).label
         & " | " & rule!CTM_displaySubInvestigatorNames(local!studyProfileSite.subInvestigator)
         &" (ID: "&ri!CTM_MONITORING_EVENT.eventID&")",
         
         "Review & Resolve Identified Issues for Protocol " &
         rule!CTM_getStudyProfileInfoById(ri!CTM_MONITORING_EVENT.studyProfileID).data.protocolNum
         & " | " & rule!CTM_getRefDataLabelById(local!site.siteName).label
         & " | " & rule!CTM_displaySubInvestigatorNames(local!studyProfileSite.subInvestigator)
         &" (ID: "&ri!CTM_MONITORING_EVENT.eventID&")"
     
     )
       )

I only see this error when running tasks that were initiated PRIOR to this code change (originally it was a generic naming label and ID#) -- I don't know why this error is thrown only in older processes and not the newer ones? What piece of data is missing? I thought at first it was missing something and passing a null value, but clearly the error has more to do with the indexing properties not matching in type, but I'm not sure where to even look to fix. 

 

Thanks

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    ou may find some success with casting the result of your query to the correct type. Ex.

    cast(typeof(type!YourCDTType()), rule!CTM_getStudyProfileInfoById(ri!CTM_MONITORING_EVENT.studyProfileID).data).protocolNum

    I also recommend avoiding dot notation when accessing values ex.

    index(cast(typeof(type!YourCDTType()), index(rule!CTM_getStudyProfileInfoById(index(ri!CTM_MONITORING_EVENT, "studyProfileID", null)), "data", {})), "protocolNum", null)

    Using index() instead of dot notation will return the third parameter instead of throwing an invalid index error.

  • Hi Josh,

    Thanks for the suggestions. I tried the cast(typeof(type!CDT) but it didn't like it -- I get this error instead now:

    Error Evaluating UI Expression
    Expression evaluation error in rule 'ctm_reviewissuesform' at function 'cast' [line 16]: Could not cast from Text to Type. Details: CastInvalid

    I'm going to try the index option now after I create a new local variable to store the multiple rule calls I'm using. May have questions on this too.

    Thanks
  • Hi Sarah,

    Yes, you need to use the index function to handle the issue however do all these calculation in a local variable inside with and use the local variable to use for label for clarity of the code.
  • 0
    Certified Lead Developer
    in reply to Sarah K.
    Hi sarah
    Please check if your CDT is multiple
    you need to use cast in loop like apply(cast(typeof(type!CDT) <CDT variable Multiple>)
  • 0
    A Score Level 2
    in reply to Sarah K.
    Hi Sarah,
    I suspect that the rule :rule!CTM_getStudyProfileInfoById(ri!CTM_MONITORING_EVENT.studyProfileID).data is not retrieving the data, In such cases use of Index function will be good as said by other folks.
  • 0
    Certified Lead Developer
    in reply to Sarah K.
    Did you use the parentheses after your type cast? Ex. type!APP_YourCDTName()
  • 0
    Certified Lead Developer
    in reply to paragk998

    Instead of using a loop you can do cast(typeof({type!CDT()), <CDT Variable Multiple>)

  • Hi Ravi, agreed on the local variable, thanks -- I successfully created the local and called it using the index() which got the form to load - success!

    Now I'm facing trouble in the User Input Task naming as I used similar code to display the task name similar to the Interface based on step, so I get this massive error in the task names now:

     

    How do I do something similar to index() but inside of the (notsofriendly) User Input Task Display Name expression editor?? The code looks like this now: 

    =choose(pv!step,"Set Resolution Due Dates & Send Initial Summary to Study Team for "
    &  rule!CTM_getStudyProfileInfoById(pv!CTM_MONITORING_EVENT.studyProfileID).data.protocolNum  
    & " | " &rule!CTM_getRefDataLabelById(pv!CTM_STUDY_PROFILE_SITE.siteName).label& " | " 
    & rule!CTM_displaySubInvestigatorNames(pv!CTM_STUDY_PROFILE_SITE.subInvestigator)
    &" (ID: "&pv!CTM_MONITORING_EVENT.eventID&")","Review & Resolve Identified Issues for Protocol "
    &  rule!CTM_getStudyProfileInfoById(pv!CTM_MONITORING_EVENT.studyProfileID).data.protocolNum  
    & " | " &rule!CTM_getRefDataLabelById(pv!CTM_STUDY_PROFILE_SITE.siteName).label& " | " 
    & rule!CTM_displaySubInvestigatorNames(pv!CTM_STUDY_PROFILE_SITE.subInvestigator)
    &" (ID: "&pv!CTM_MONITORING_EVENT.eventID&")")

    Thanks all!

Reply
  • Hi Ravi, agreed on the local variable, thanks -- I successfully created the local and called it using the index() which got the form to load - success!

    Now I'm facing trouble in the User Input Task naming as I used similar code to display the task name similar to the Interface based on step, so I get this massive error in the task names now:

     

    How do I do something similar to index() but inside of the (notsofriendly) User Input Task Display Name expression editor?? The code looks like this now: 

    =choose(pv!step,"Set Resolution Due Dates & Send Initial Summary to Study Team for "
    &  rule!CTM_getStudyProfileInfoById(pv!CTM_MONITORING_EVENT.studyProfileID).data.protocolNum  
    & " | " &rule!CTM_getRefDataLabelById(pv!CTM_STUDY_PROFILE_SITE.siteName).label& " | " 
    & rule!CTM_displaySubInvestigatorNames(pv!CTM_STUDY_PROFILE_SITE.subInvestigator)
    &" (ID: "&pv!CTM_MONITORING_EVENT.eventID&")","Review & Resolve Identified Issues for Protocol "
    &  rule!CTM_getStudyProfileInfoById(pv!CTM_MONITORING_EVENT.studyProfileID).data.protocolNum  
    & " | " &rule!CTM_getRefDataLabelById(pv!CTM_STUDY_PROFILE_SITE.siteName).label& " | " 
    & rule!CTM_displaySubInvestigatorNames(pv!CTM_STUDY_PROFILE_SITE.subInvestigator)
    &" (ID: "&pv!CTM_MONITORING_EVENT.eventID&")")

    Thanks all!

Children