Cast error

Hi All -- I'm stuck trying to get a 3rd CDT to pull into my interface using a query rule that has an input from a local variable... here is the error: 

load(
  
  local!ResolveIsssuesProcessId: rule!CTM_getAllResolveMonitoringFormIssuesProcessIdsByEventId(ri!monitoringEvent.eventID),
  local!formID: rule!CTM_getMonitoringFormByEventID(ri!monitoringEvent.eventID),
  local!formQuestions: rule!CTM_getFormQuestionDetailsByFormID(local!formID),

These are my local variables and here is the query rule that's throwing the error:

In the interface I am trying to save the local!formQuestions into a CDT as an array....why does it think I want to save it as an integer?? 

Instead of using a query rule to pass into the local!formQuestions I also tried an Expression rule that actually returns all the CTD's data but it is also an array of data which doesn't like being saved into the local, I get the same cast error. 

 

Thanks for any help!

  Discussion posts and replies are publicly visible

Parents
  • Hi Sarah,

    It's looks like your passing dictionary insted of id. Try the following code:

    load(

    local!ResolveIsssuesProcessId: rule!CTM_getAllResolveMonitoringFormIssuesProcessIdsByEventId(ri!monitoringEvent.eventID),
    local!formID: rule!CTM_getMonitoringFormByEventID(ri!monitoringEvent.eventID).data,
    local!id: tointeger(index(local!formID, "formID",{})),
    local!formQuestions: rule!CTM_getFormQuestionDetailsByFormID(local!id),
    )

    if you have list of id's use a!foreach to retrive all form question s for all id's

    load(
    local!ResolveIsssuesProcessId: rule!CTM_getAllResolveMonitoringFormIssuesProcessIdsByEventId(ri!monitoringEvent.eventID),
    local!formID: rule!CTM_getMonitoringFormByEventID(ri!monitoringEvent.eventID).data,
    local!id: tointeger(index(local!formID, "formID",{})),
    local!formQuestions: a!foreach(
    items: local!id,
    expression: rule!CTM_getFormQuestionDetailsByFormID(fv!item)
    )
    )
  • Hi nareshc647 thank you so much! This resolved the cast error, but now instead of only saving the ID I'd like to save the entire array of CDT -- is this possible? What you provided helps get rid of the cast error, but there are still in fact an array of formQuestionID's that need to get saved into the CDT... how do I achieve this?

    I want this rule input to be saved with the entire CDT for all rows -- the whole array. 

Reply
  • Hi nareshc647 thank you so much! This resolved the cast error, but now instead of only saving the ID I'd like to save the entire array of CDT -- is this possible? What you provided helps get rid of the cast error, but there are still in fact an array of formQuestionID's that need to get saved into the CDT... how do I achieve this?

    I want this rule input to be saved with the entire CDT for all rows -- the whole array. 

Children
  • 0
    A Score Level 2
    in reply to Sarah K.
    Yes, It is possible. I think your saving local!formQuestions in a rule input. As per my guess the return value of local!formQuestions is a data dictionary. To pass that local variable to rule input you need list of variant values.

    Try with this

    For single id:
    local!formQuestions: rule!CTM_getFormQuestionDetailsByFormID(local!id). data

    For multiple IDs

    local!formQuestions: a!foreach(
    items: local!id,
    expression: rule!CTM_getFormQuestionDetailsByFormID(fv!item).data
    )

    if you still get any cast error issues use the bellow sample code

    local!formQuestions: cast(
    typeof({'type!formCDT(your rule input cdt)}),
    rule!CTM_getFormQuestionDetailsByFormID(local!id). data)
  • Thanks again for the help; the .data doesn't pass anything into my CDT input, I'm guessing because the FormID is not the primary key for that data type.... hence my ongoing issue. But FormID is the connecting piece of data that ties together the EventID and FormQuestionID -- how do I handle this?