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

  • 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.

  • +1
    Certified Lead Developer
    in reply to appianfreak

    BTW, when you post code, you should consider using a Code Box, by hitting "Insert" -> "Insert Code".  This will preserve formatting/indenation, and give a nice size-constricted display box to keep the comment from wasting an undue amount of space within the conversation.

    For instance, here's the same code as above, except I've added the filter value (and set the applyWhen parameter as well).  I used "ri!inputId" but you can use whatever your rule input is called.

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

    Edited to add:  I also notice you're not referencing the ".data" of the rule's dataSubset output (as I suspected earlier, which is why I was asking you to post the sample output of this rule to confirm).  So, before you can expect get any data properly saving into your in-process PV, you will need to add ".data" either within the expression rule (at the very end of the a!queryEntity() call), or in the process model itself after the expression rule call.  I.E.,

    rule!VFM_getVehicleById(inputId: pv!updateId).data
  • Thank you for the Code Box tip!

    Is it possible for the Query Editor to generate the code I now see I'm missing? I was imagining Appian automagically inserts it when query is run. Obviously I see I'm wrong now.

    I needed to include the rule input against the filter for the generated SAIL expression to include it! Doh!

    On to next problem.

  • 0
    Certified Lead Developer
    in reply to appianfreak
    Is it possible for the Query Editor to generate the code I now see I'm missing?

    I don't have much experience using the (relatively new) Query Editor as I'm used to just writing any necessary query entities by hand.  In general my suggested approach for using it would pretty much always be to use it only to quickly establish a basic query that works, and then tweak it per your needs in the Expression Rule editor (and also test it there, etc).

  • The frustrating part I've found about Appian, is that things stop working at random for no reason. Just after I made the change you told me, it worked twice and then again without me changing anything, it stopped working. Most of the times unpublishing / publishing application solves the issue, but not today. 

    The process model picked up the modification to the getVehicleById(), then I removed the debut TEXT pv and now it will not pickup the change.

    It's the weekend...Anyways, thanks again for your help. Learned something today.

  • Okay so I figured out my problem. I don't think the instructions in the tutorial are clear.

    When I have a Query Expression Rule, what I get back is an object of type DataSubset.

    When I'm asking Script Task Custom Output to save the results to my CDT, it does not work. My first question is why is Appian not throwing an error when I'm trying to assign a 'DataSubset' to a 'Vehicle'? Pressing question is how do I extract the 1 Vehicle instance in my Dataset?

    What I did was typename(typeof(rule!VFM_getVehicleById(pv!vehicleId))) to realize I"m getting a Dataset back and not a Vehicle. I was blindly following screenshot in the tutorial to my detriment.

    So right now I'm trying to assign the results of expression rule!VFM_getVehicleById(pv!vehicleId) to pv!vehicle. I need to modify the expression to yield the embedded CDT. Can anyone help?

  • 0
    Certified Lead Developer
    in reply to appianfreak

    This is what I was attempting to show you in several of my previous replies...

  • Sorry if I'm being dense. I need some SAIL expression I'm thinking to extract the Vehicle. If you showed that somewhere, I'm missing it. 

    EDIT: Doh! I see it now. follow expression with ".data".

    BUT Question No 1. How can Appian not throw up when I try to assign a DataSet to a Vehicle? How is there no error generated? If It did, my mistake would have been so obvious. Am I suppose to configure Exception tab to see error?