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

  • 0
    Certified Lead Developer
    in reply to appianfreak

    To get the data from the data subset, you add ".data" either after the query entity expression, or after the expression rule where you call it.  Note that I talked about this and also put it into one of my more recent code examples above.

    Appian doesn't give an error because it freely allows types to be cast as other types, and it has no inherent way of knowing whether you're trying to do a valid typecasting or not.

  • Okay, forgive me but that seems a bit lame. Casting a "Date" to a "Text" or vice versa I can understand. Date can be converted to Text with a tostring operation. Text can be converted to Date assuming the Text carried date in some valid format, e.g. MM/dd/yyyy.

    On what planet would a DataSet with multiple attributes when cast to a type of CDT not throw error? It would be one thing if it actually worked, because Appian would smartly assume assignment is to a CDT so let's see if "data" attribute of the DataSet is of that type. But it didn't do that. which is fine, but then not throwing error?

    I may be new to Appian, but I am finding it very hard to buy this logic. If there's some article explaining how Appian implemented casting behavior I would appreciate it. Else I'm going to have to keep writing complicated SAIL expressions. And then "low code" goes out the window.

  • 0
    Certified Lead Developer
    in reply to appianfreak

    Not sure what to tell ya then.  Type casting will attempt to work between any two complex types as far as I know and will use any fields named the same.  Particularly because it would let me cast a type containing "name", "id" and a hundred other fields, for example into a special CDT containing just "name" and "id".  But if there are no common properties between the two types, then the resulting cast operation will result in blank data, such as what you were seeing.

  • Okay, the definition of casting then is "if I want to assign two CDTs to each other and they contain same properties, it is convenient". It then also explains why Appian didn't throw an error. VERY important learning for me. I thank you again for your patience and persistence with me.

Reply Children