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
Reply
  • 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
Children