IPA node assignment and null values

 2 Replies
 1 Subscribed to this topic
 52 Subscribed to this forum
Sort:
Author
Messages
DavidV
Veteran Member
Posts: 101
Veteran Member

    Just curious what the best practice is with node assignment and dealing with null or undefined values.  We have a capital req approval flow that is based upon the reqline_PO_CODE  -- We assign reqline_PO_CODE to a variable called PO_CODE and then in a branch node check the value for that variable.  In the assignment node we had:

    Variable name: PO_CODE

    Variable type: String

    Variable value: reqline_PO_CODE 

    This would work fine when the requisition had a PO_CODE but would error with "Error evaluating expression..." if the requisition didn't have a value.  Basically it was null.  So I was going to change the Variable value to :

    Variable value:

    if (typeof reqline_PO_CODE == "undefined")
    {
    null
    }
    else
    {
    reqline_PO_CODE
    }

    Or should I use some other method?

     

    jamesraceson
    Veteran Member
    Posts: 52
    Veteran Member
      DavidV,

      For our flows, we have a little data check function that I call (either within an Assign node or you could add it to the pflow.js to make it a global function). This takes the input and makes it a string, but most of the time we are passing strings to an AGS call anyways (even if the values are numeric, they will be changed in the call when the data is imported in anyways). You could also just return the original value if it passed the check so that way you wouldn't worry about changing it to a string. Just an idea of what we do that works for us. There are definitely different ways to do the same thing (using Boolean "flags", checking lengths, etc.).

      
      function DataCheck(queryField)
      {
      	var goodValue = String(queryField);
      
      	if (typeof(goodValue)=='undefined' || goodValue=='null')
      	{
      		goodValue = '';
      	}
      	
      	return goodValue;
      }
      
      jamesraceson
      Veteran Member
      Posts: 52
      Veteran Member
        Arrrghh. Ok, the ampersand pound sign 39's are single quotes.