The CreatorCon Call for Content is officially open! Get started here.

Inbound web service that can both create and update incidents?

peterraeves
Mega Guru

We are creating an Inbound Web Service that can do 3 things. Create, update and close an Incident. What would best practice be here? Should I create 3 services? Should I create a single Service with 3 transform maps? Should I create a single service with a single TM that covers all situations?

I thought about all situations but all of them had bad points to them. So I thought I'd turn to you guys who are much smarter than me.

1. 3 Services & 3 Transform Maps

+: Easier for the external customer, as the name of the service is clear and they will receive only a single result

-: Double work for field maps/values that are the same for all services

2. 1 Service & 3 Transform Maps

+: Single interface, so customer does not need to worry about what to call

+: Only need maps for those fields that are needed for the current service

-: The external customer will receive the results of 3 TMs

-: All TMs need onBefore maps to check whether they should run

-: Double work for field maps/values that are the same for all services

3. 1 Service & 1 Transform Map

+: Everything is centralized

-: Cannot use coalesce field 'number', because it will not be present when creating a new ticket. This will cause the TM to fail.

PS: As a bonus question, where should I put default values. For example, for the contact_type field, I'd like to enter 'Automated Event', which is not the overal default. Where would I put this assignment? Field Map? Transform Script?

1 ACCEPTED SOLUTION

If you check 'Coalesce Empty Field' it'll stop complaining.   That's what we do and it has worked for 2 years now.   If you don't have a coalesce field, how is it going to know what to update?   Even with Table API, you have to pass something to tell it what to update.


View solution in original post

11 REPLIES 11

Chuck Tomasi
Tera Patron

For this level of complexity, I recommend a scripted (SOAP) web service or a scripted REST API. It gives you control over what parameters you pass and what actions the API takes, including what response you get back.



Scripted REST APIs


http://wiki.servicenow.com/index.php?title=Scripted_Web_Services


It's not really that complex though. The biggest issue I'm dealing with is really something simple. I would like to use number as coalesce field, but do not want to tell the customer to enter the field empty to create a message, because that's just ugly. I expected ServiceNow to handle the missing coalesce variable as it being a new record


Mike Allen
Mega Sage

I used 1 table with coalescence on the sys_id.   That way, the only thing anyone ever calls is insert.   It goes into a staging table and the single transform map picks up from there.   If there is no reference sys_id given, it inserts.   If there is a reference sys_id, it updates the parent record.   If the state is close, it updates the record and closes it.



Your response on the initial insert will give you the sys_id of the record created.   Just capture that and pass it with each subsequent call to do updates.


As an answer to your bonus question, I put these in the Field Map.   Just map it from script and make the answer equal your value.