Populate Catalog Item Variable with REST Call with Immediate Results Displayed

ctsmith
Mega Sage

I have a REST integration that pulls in application names from a 3rd party into a custom SN table when the form loads using an onLoad catalog client script that references a script include. There is a variable on the catalog item that is linked to the names on the custom table so a user can pick from the list of names brought in from the 3rd party API.

The problem I'm having is that the variable only shows the results from the last call to the 3rd party application.   For example, User 1 opens the form and the call brings in applications A, B, and C from the integration that performs the REST integration function onLoad.   This user tries to select from the list in the variable, and it's empty.

User 2 opens the form and the call brings in applications D and E.   User 2 tries to select an app from the variable list, and User 2 only sees A, B, and C from User 1's call, but not D and E from User 2's call.

And so on...   it will always be one behind.

Thoughts?


Thanks!

Chris

21 REPLIES 21

@Harriet 

No worries! I have a much more recent solution I used for this.

Create a scheduled script execution job under a new scheduled job.  When you create a new scheduled job, it gives you the option "Automatically run a script of your choosing."

In the script, call your outbound REST message.  If you haven't created this already and need help, let me know.

The script in your scheduled job would then parse out the response from outbound REST call and you can store these values in a table with a GlideRecord newRecord.

In my case, I created an import table and a transform map that is triggered when the table is populated from the REST call.  From there, the transform maps it to where it needs to go with the right values parsed out from the response message.  I mapped to the cmdb switches table since that's what I was pulling from the REST call.

In your case, you are getting IP addresses.  You could store those in the IP cmdb table and then create a reference variable that filters on those addresses from that table.

 

Hello, @Christopher Smith ,

Thank you so much!!

No, I have not created my outbound REST message yet. Do you have an example? 

I'm trying to extract just the network portion of the JSON response body.

Example:

 

[

    {

        "_ref": "network/ZG5zLm5ldHdvcmskMTky: 123.456.78.90/30/default",

        "network": "123.456.78.90/30",

        "network_view": "default"

    },

    {

        "_ref": "network/ZG5zLm5ldHdvcmskMTky:123.456.78.90/30/default",

        "network": "123.456.78.90 /31",

        "network_view": "default"

    },

    {

        "_ref": "network/ZG5zLm5ldHdvcmskMTk:123.456.78.90/30/default",

        "network": "123.456.78.90 /32",

        "network_view": "default"

    }

]

So I end up with just:

123.456.78.90/30
123.456.78.90/31
123.456.78.90/32

Thanks!
Harriet

 

Hi @Christopher Smith   ,

Do you have update on this? Thanks in advance!

Harriet

 

Hi @Christopher Smith
I figured out how to create the outbound REST message and for the script to call it. 
Thanks again for your help!

Best regards,
Harriet

 

Hi @Christopher Smith ,

Would you be able to provide additional guidance on how to store the values in a table with GlideRecord newRecord?  I have a working script in my scheduled job that calls the outbound REST message and parses out the response from it.

Any information you can provide, I very much appreciate it.

Thanks in advance!
Harriet