How to execute an API call from clicking a button on the Service Catalog Order form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2019 04:56 AM
Hi,
I have read several SNOW docs and many posts from the community and I am still not able to get this to work. It could be my lack of experience with web or sp coding although I do support the Service Catalog and Service Portal at our site. Or I'm just not looking for the correct info.
We have a process in place now that utilizes REST to do the same API call that I want to use. Besides the REST message there is a Script Include and a Catalog Client (onChange) Script. On the order form there is a single line text variable where the user enters an ID. This ID is a unique field in an external non-servicenow database. Once the focus moves out of the field the API call is executed and several other variables are populated from data in that database.
Now we want to expand on this functionality by taking the same ID and performing another API call and this time retrieving ALL the fields of the record instead of just the few we need in the RITM/SCTask records. When we retrieve them we just want to display them in a pop up form for review. Once the review is complete then the user clicks the Close button and the form goes away.
Once I get this working my next goal is to have this same functionality available in RITM and SCTask records via a Related Link or a button on the form.
First things first however. I have created a Widget to act as a button on the form under the aforementioned ID field. I want to take that input and use it in my separate call to retrieve the data.
I copied some code from elsewhere in the tool using spModal and I can display the pop-up form with a Title at the top and a Close button at the bottom. I have since been able to add a few column headers and if I ever get this to work hopefully the appropriate data will display under those headers.
I've been trying to utilize the existing code so I don't have to completely recreate the process but I am not able to successfully access the other database. I have tried several ways to do this, mostly from within the Widget trying to run the Script Include.
The widget is running off of another variable I created as it is how I get it to display on the Order Form.
I'm not looking for anyone to provide code for the whole process but at least as a start, a way to get to the external database from the Widget. Unless of course there is a better way to do this altogether.
Thanks,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2019 06:23 AM
Sure but it will take a little while as I cannot simply copy and paste. I wish I could...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2019 06:57 AM
This has gone through a few permutations, one of which was adding column headers where the 'Still working on it' text is but this is as it is now.
HTML:
<div>
<button class="btn btn-primary" ng-click="c.openModal()">${Click here to display the 'external db' Record information}</button>
</div>
<script type="text/ng-template" id="modalTemplate">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">external db Record Display</h4>
</div>
<div class="panel-body wrapper-xl">Still working on it. Try back later.</div>
<div class="panel-footer text-right">
<button class="btn btn-primary" ng-click="c.closeModal()">${Close external bd Window}</button>
</div>
</div>
</script>