Automic Workload Automation

 View Only
  • 1.  How to check if array variable is initialized

    Posted Nov 12, 2019 04:19 PM
    Hi all,

    I am parsing a REST response using JSONPath to output into an array variable. When I try to use the array there are errors if the web service response is empty (The array 'ARRAY#' has not yet been defined.

    How can I check if the variable has been assigned?

    I have seen some other users post a workaround to set the variable to itself, but this does not work with arrays in my testing.

    Thanks for any info!


  • 2.  RE: How to check if array variable is initialized

    Posted Nov 12, 2019 05:25 PM
    Update: It seems that Process tab of REST web service job does not ever get executed, maybe this is the reason the workaround is not working. Does anyone have a suggestion?


  • 3.  RE: How to check if array variable is initialized

    Posted Nov 13, 2019 03:14 AM
    The process tab does get executed, but you might want to go for the post-process tab else you would need to :RSET instead of :SET. What you also might to is "write to job report" instead of saving data in a variable and then use prep_process_report in the post process.

    I'm not a fan of the webservice object. It tries to ease the work with webservices but it often fails and makes things more complicated.

    ------------------------------
    Swisscom Automation Engineer & PE Membership Creator

    Entfessle mehr Automic Wissen mehr Automic Tools
    https://membership.philippelmer.com/
    ------------------------------



  • 4.  RE: How to check if array variable is initialized

    Posted Nov 13, 2019 09:26 AM
    Automic needs an isnull function.

    I found the array function in rest response to be more trouble than it is worth.  When you choose false and get array data it gives you a comma separated list.  You can then check this for content and if it is there split it on the comma.

    for instance:
    rest returns &VARA#

    post tab
    :SET &VARA# = STR_CAT (&VARA#.'') ! set the string to at least empty in case it was null
    :DEFINE &VARA_ARRAY#, STRING, 50
    :FILL &VARA_ARRAY#[] = STR_SPLIT(&VARA#,",")

    !Do array stuff

    --

    Scott Hughes

    IT Network Services

    O 949 286 7668
    M 505 373 7872
    7000 Central Blvd SW
    Albuqurque
    Albuqurque, New Mexico 87121






  • 5.  RE: How to check if array variable is initialized
    Best Answer

    Broadcom Employee
    Posted Nov 13, 2019 08:18 AM
    To check if a variable is defined you should be able to use the GET_SCRIPT_VAR function, have not tried with array but this is what i use to check if a variable is already defined
    https://docs.automic.com/documentation/webhelp/english/AA/12.3/DOCU/12.3/Automic%20Automation%20Guides/help.htm#Script/Reference/GET_SCRIPT_VAR.htm
    SET &TEST# = GET_SCRIPT_VAR("ARRAY#")