Error in ER

Certified Associate Developer

can anyone please give suggestion how to resolve this error ?

  Discussion posts and replies are publicly visible

Parents Reply Children
  • 0
    Certified Lead Developer
    in reply to jojog0003

    In your second rule where you are checking the time entry cdt field difference, add a typecasting logic so that both the values in comparison are of same type.

     eg. value1=value2 can be replaced as cast(typeof(value2),value1)=value2 

    In your case value1 i.e. the old record might be null and thus when you are trying to compare that to value 2, having an integer field in it casting error is coming. By using cast() you can make both the values of the same type so that comparison can happen.

  • 0
    Certified Associate Developer
    in reply to Harsha Sharma

    Hi Harsha,

    Thank you for your response. I am new to Appian Developing so I am trying to understand where i can apply typecasting. could you please help me for this.

  • 0
    Certified Lead Developer
    in reply to jojog0003

    Use in line 6 of your rule cdm2_gettimeentrycdtfielddiff where you have condition and(index(oldCDTentry...)=index(newCDTEntry...) 

    try replacing that with 

    and(cast(typeof(index(newCDTEntry,ri!fields[ri!index],{})),index(oldCDTentry...))=index(newCDTEntry...) 

  • 0
    Certified Associate Developer
    in reply to Harsha Sharma

    Hii Harsha,

    Is still gives error . I am insert full code below .please help me out.

    if(
     and (
        /*To catch lists of values*/
        index(ri!oldTimeEntryCDT, ri!fields[ri!index], {}) =
        index(ri!newTimeEntryCDT, ri!fields[ri!index], {})
      ),
      ri!currentString,
      concat(
        ri!currentString,
        if(
          or(
            isnull(index(ri!oldTimeEntryCDT, ri!fields[ri!index], {})),
            isnull(index(index(ri!oldTimeEntryCDT, ri!fields[ri!index], {}), "value", {}))
          ),
          /*If there was no old field, just show current value*/ 
          if(
            /*Nested CDT lookup fields have "selection" in their field type*/
            search("SELECT", ri!fieldTypes[ri!index]),
            ri!fieldNames[ri!index] & ": " & joinarray(index(index(ri!newTimeEntryCDT,ri!fields[ri!index],{}), "value", {}) & char(10), ", "),
    
            if(
              /*Record fields can't display their title for security reasons*/
              search("record", ri!fieldTypes[ri!index]),
              ri!fieldNames[ri!index] & " record value selected" & char(10),
    
              if(
                /*Since paragraph fields can contain long values, only show the first 200 chars*/
                search("PARAGRAPH_REFERENCE", ri!fieldTypes[ri!index]),
                ri!fieldNames[ri!index] & ": " & left(index(index(ri!newTimeEntryCDT, ri!fields[ri!index], {}), "value", {}), 200) & char(10),
    
                if(
                  /*Certain older paragraph fields are direct fields of the main CDT, instead of nested children,*
                   *so we don't have to index into their value field.*/
                  search("PARAGRAPH", ri!fieldTypes[ri!index]),
                  ri!fieldNames[ri!index] & ": " & left(index(ri!newTimeEntryCDT, ri!fields[ri!index], {}), 200) & char(10),
    
                  /*For primitive fields (text, date, number) just read out the value*/
                  ri!fieldNames[ri!index] & ": " & index(ri!newTimeEntryCDT, ri!fields[ri!index], {}) & char(10)
                )
              )
            )
          ),
          /*Otherwise, show old and new values*/
          if(
            /*Nested CDT lookup fields have "selection" in their field type*/
            search("SELECT", ri!fieldTypes[ri!index]),
            ri!fieldNames[ri!index] & ": " & 
            joinarray(index(index(ri!oldTimeEntryCDT,ri!fields[ri!index],{}), "value", {}), ", ") & " ➝ " &
            joinarray(index(index(ri!newTimeEntryCDT,ri!fields[ri!index],{}), "value", {}), ", ") &
            char(10),
    
            if(
              /* Record fields can't display their title for security reasons */
              search("record", ri!fieldTypes[ri!index]),
              ri!fieldNames[ri!index] & " record value changed" & char(10),
              if(
                /*Since paragraph fields can contain long values, only show the first 200 chars*/
                search("PARAGRAPH_REFERENCE", ri!fieldTypes[ri!index]),
                ri!fieldNames[ri!index] & ": " &
                left(index(index(ri!oldTimeEntryCDT, ri!fields[ri!index], {}), "value", {}), 200) & " ➝ " &
                left(index(index(ri!newTimeEntryCDT, ri!fields[ri!index], {}), "value", {}), 200) &
                char(10),
    
                if(
                  /*Certain older paragraph fields are direct fields of the main CDT, instead of nested children,*
                   *so we don't have to index into their value field.*/
                  search("PARAGRAPH", ri!fieldTypes[ri!index]),
                  ri!fieldNames[ri!index] & ": " &
                  left(index(ri!oldTimeEntryCDT, ri!fields[ri!index], {}), 200) & " ➝ " &
                  left(index(ri!newTimeEntryCDT, ri!fields[ri!index], {}), 200) &
                  char(10),
    
                  /*For primitive fields (text, date, number) just read out the value*/
                  ri!fieldNames[ri!index] & ": " &
                  index(ri!oldTimeEntryCDT, ri!fields[ri!index], {}) & " ➝ " &
                  index(ri!newTimeEntryCDT, ri!fields[ri!index], {}) &
                  char(10)
                )
              )
            )
          )
        )
      )
    )

  • 0
    Certified Lead Developer
    in reply to jojog0003

    Just replace the code from line 2-6 as below and see if it resolves the issue. 

    and (
        /*To catch lists of values*/
        cast(typeof(index(ri!newTimeEntryCDT, ri!fields[ri!index], {})),
        index(ri!oldTimeEntryCDT, ri!fields[ri!index], {})) =
        index(ri!newTimeEntryCDT, ri!fields[ri!index], {})
      )

  • 0
    Certified Associate Developer
    in reply to Harsha Sharma

    Hi Harsha,

    Thank you so much for your response. its working fine now.