Process Variable not getting assigned with DSE

I have a rule to fetch DSE from database. Debugged and works fine.

In my process model, I'm using pkId to lookup data using my rule and then assigning it to a process variable. Unfortunately my process variable is not getting assigned. When I debug the process, I don't see any errors and I've double checked my rule for fetching data and that I'm passing id correctly.

On the Data Output tab of my script task I'm calling the rule - rule!GetDataById(pv!myId) with a Custom Output. myId is populated with value e.g. 4, and I see it when I debug

I'm storing the results in process variable for my entity. However, after I let the script task finish and check my process variables, my entity object is empty.

This should just work :-( 

What obvious thing could I be missing?

  Discussion posts and replies are publicly visible

Parents Reply Children
  • Yes of course. See, the pv is indeed of the correct CDT type, because only then am I able to populate data on UserInputTask form and save to Database through the DSE. All this works perfectly.

    To boil it down to code for the Custom Output configured on Data->Output tab of my Script Task which I introduced prior to the UserINputTask

    rule!VFM_getVehicleById(updateId) /* where updateId = 4 (say) based on record selected */

    "save into" vehicle, where vehicle pv is of type CDT. I'm not typing anything, but selecting from UI so I know I'm doing this correctly.

    Basically my Script Task Custom Output configuration is not working. I'm not able to tell if for any reason VFM_getVehicleById() is failing - it really can't because I can see it is getting a valid "updateId" value passed in - or Appian is not saving CDT instance returned into pv!vehicle.

  • 0
    Certified Lead Developer
    in reply to appianfreak

    Sorry, then I misunderstood what you were referring to when you said your PV was "data store entity" type.

    Can you confirm / post a screenshot of the output of rule!VFM_getVehicleById() when passing in an example id, within the expression rule editor?  For example, sometimes people forget to reference the ".data" in the query entity output, to get the CDT type data itself as opposed to the DataSubset returned by default by a!queryEntity.

  • Unfortunately "Security" at my sight is blocking me from pasting screen shots at this time. If/When I'm able I will post the screenshot.  If you can visualize with me. It is exactly like in the Appian tutorial lesson.

    On the Data Output Tab,

    On the left, I have 

    Custom Outputs

    rule!VFM_getVehicleById(pv!updateId)

    On the right, I have Expression Properties...

    Expression: rule!VFM_getVehicleById(pv!updateId)

    Operator: is stored as

    Target: vehicle

  • 0
    Certified Lead Developer
    in reply to appianfreak

    Thanks for clarifying your process model configuration -- that sounds right to me.  But what I'm actually asking for is the exact output of the rule itself.  When you open VFM_getVehicleById, and run it, what do you see in the "Test Output" section?

  • Okay...So this is what I did.

    Instead of setting my updateId process variable to 0, I set it explicitly to 4 (which I know is a good id for a vehicle in database)

    I started process for debugging. I see updateid as 4 on Process Details VAriables tab. So eliminated Record Action not passing data possibility.

    I refreshed to move past the Script Task and land at the User Input Task. By this point, my vehicle pv should have been populated. When I look at my Variables tab again I can see it is *not* populated.

    So I can tell you 4 is a valid Id. I can tell you getVehicleById(4) should not fail. I have tested this and it works. I've removed any doubt 4 was not getting passed from Record Action to Process instance. BUT I cannot tell if when my rule was called to fetch the data whether it worked or not, because the only way to check is looking at what's in vehicle pv.

    Is there a way to debug/trap data returned from the fetch rule *before* Appian populates it into vehicle pv? That would tell me once and for all for whatever reason my fetch rule works everywhere else *but* not from within my Script Task.

  • 0
    Certified Lead Developer
    in reply to appianfreak
    Is there a way to debug/trap data returned from the fetch rule *before* Appian populates it into vehicle pv?

    Yes - as I said before, open VFM_getVehicleById in the Expression Rule editor, enter your id input (4), and click "Test Rule".  Have you done this already?  And if so, what is the exact result?

    If you want to "trap" the rule's output within the process model only (i.e. you think it's already working when viewed from the expression rule editor), you can create a new (temporary) TEXT PV, and save the same query result (wrapped in the toString() function) into it.  This will generally tell you whether any data at all is being returned from the query when the process is run, for instance if it's something that's returning data but not matching the CDT type of the original target PV.

  • Okay, sorry if I'm bad at replying. When I said I know for a fact my VFM_getVehicleById() works it is indeed because I tested it independently by passing 4 as parameter. It returns all the field properties as it is supposed to just fine.

    I will try the TEXT pv trick you suggest and reply back ASAP editing this post. Thank you very much for your patience!

  • 0
    Certified Lead Developer
    in reply to appianfreak
    When I said I know for a fact my VFM_getVehicleById() works it is indeed because I tested it independently by passing 4 as parameter.

    I believe you that it works, in general, but that's not the reason I'm asking.  I want to know what the exact output is, since there are a few different possible mistakes I've commonly seen (and made myself a few times) that I want to verify against -- which I'd have to see the exact output of the rule in order to be sure of.

  • I feel like an idiot. I said it was working. Yeah...working INCORRECTLY!

    My filter is not getting applied to return only 1 Record with Id = 4. I do have filter defined with "Always". Problem is whether I pass argument or not, always ALL records are getting returned. So obviously on my Record Display when I'm calling rule without arguments it returns all and I say "it is working", but when I pass only parameter = 4, it STILL returns everything when executing in the Process Model, which is obviously the problem.

    Code is below. If you can kindly spot where I have (obviously) messed up

    a!queryEntity(
    entity: cons!VEHICLE_DSE_VFM,
    query: a!query(
    logicalExpression: a!queryLogicalExpression(
    operator: "AND",
    filters: {
    a!queryFilter(
    field: "id",
    operator: "="
    )
    },
    ignoreFiltersWithEmptyValues: true
    ),
    pagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: 50
    )
    ),
    fetchTotalCount: false
    )

    PS - In the Query Editor, when I pass argument it DOES return only 1 row, but the generated SAIL query does not work when used within Process Model.

  • 0
    Certified Lead Developer
    in reply to appianfreak

    Well, the first thing I see is that your queryFilter has nothing being passed in for the "value" parameter - you'd need to at least add that, or else it wouldn't do anything.