PO State Change via REST API – Requested to Ordered Not Working

deepaktomar
Tera Contributor

Hello Community,

I am automating the procurement flow in ServiceNow via REST APIs from a Node.js application.

Current status:

   - Service Request and RITM are created successfully

   - Purchase Order and PO Line Items are created

Issue: When updating the Purchase Order state from Requested to Ordered via REST API, the API always returns 200 OK, but the state does not change

 

I also plan to:

  - Perform PO receiving via API

  - Create assets dynamically via API after receiving

 

Questions:

1. Is the full PO lifecycle (Requested → Ordered → Received → Asset creation) supported via REST APIs in ServiceNow?

2. If not recommended, what is the correct technical justification (platform constraints, internal workflows, UI actions, etc.)?

3. Even if achievable, is driving the entire purchase flow externally via APIs considered a best practice, or should this remain within ServiceNow workflows?

 

Looking forward to expert guidance.

Thanks.

 

3 REPLIES 3

Brad Bowman
Kilo Patron

In your environment, if you manually view a PO that is created by this process, are you able to manually change the State from Requested to Ordered, or is there a mandatory field or something preventing this update?  In the REST API payload, are you using the correct field name 'status' and value 'ordered'?

deepaktomar
Tera Contributor

Hi @Brad Bowman  ,

Yes, the State field on the Purchase Order form is read-only (greyed out), so you cannot directly edit it. However, you can change the State from Requested to Ordered by clicking the Order action button at the top of the form. This action updates the State internally as shown in the screenshot below.

deepaktomar_0-1765961982206.png


Thanks.



Brad Bowman
Kilo Patron

Out of the box, the 'Order' UI Action is only updating the status field to 'ordered', and there is nothing in place to prevent this via script, so unless you have customizations in your instance it should work.  Try a simple fix script on an existing PO record like:

var po = new GlideRecord('proc_po');
if (po.get('39e8bb6c37423000158bbfc8bcbe5d4b')) {
	po.status = 'ordered';
	po.update();
}

Does this work? Are you doing the same via API or also attempting other updates simultaneously?  Does anything show in the system logs when the API runs?