Has anyone had luck creating Purchase Orders through the API with multiple Approval levels?

I'm able to create Purchase Orders using the API without any issues. I can also create purchase orders with a single approval level. Where I'm struggling is when trying to create a purchase order with multiple approval levels. At this point I've run out of ideas and would love any input. Thanks!

What I've tried so far

I tried following the API documentation but haven't been having much luck.

https://apidoc.samanage.com/#tag/Purchase-Order/operation/createPurchaseOrder

"approval_levels_attributes": [
  {
    "id": "1",
    "approver_ids": "1, 2",
    "approval_condition": "1"
  }
],

With some trial and error, I was able to figure out the following:

  • I'm not sure how id is used, and leaving undefined still allows creating a PO with a single approval level.
  • approver_ids is a comma separated string of "group" ids for the different approvers.
  • approval_condition seems to be the "Only one approver", "All approvers", or "50% or more approvers"

I initially assumed each "level" would just be defined as a separate item in the list, but that actually doesn't work and sort of breaks the approvals, creating a duplicate of the Level 1 approval that the system ignores .

"approval_levels_attributes": [
    {
        "approver_ids": ""6712085",
        "approval_condition": 1
    },
    {
        "approver_ids": "6712085,6828711",
        "approval_condition": 1
    }
]
  

I also tried checking the network traffic when submitting from the web. Submitting a PO with these approval levels were submitted as a form with this attribute breakdown:

  

I tried resubmitting as a list of approval levels in the two following ways:

  1.  This payload actually ended up having the same error as submitting list the list of approvals above, with a duplicate Level 1 approval.
    "approval_levels_attributes":{
        0: {
            "approver_ids": data.pop("approvers"),
            "approval_condition": 1
        },
        1: {
            "approver_ids": "6712085,6828711",
            "approval_condition": 1
        }
    }
            



  2. This payload, the closest to the actual documented payload, weirdly gave me a 404 error...
    "approval_levels_attributes": [
        {
            "id": "0",
            "approver_ids": "6712085",
            "approval_condition": 1,
        },
        {
            "id": "1",
            "approver_ids": "6712085,6828711",
            "approval_condition": 1,
        },
    ]

  • Hey
    You can create the Purchase Order with multiple Approvals level with the API using the level.

    You need to  add level  part of the approval_levels_attributes
    Here is an example of a request 
    You need to modify the values according to the relevant data.
    {
      "purchase_order": {
        "name": "test 222222344",
        "buyer_id": "272751",
        "buyer": {
          "email": "guy.frieman@solarwinds.com"
        },
        "order_date": "May 30, 2023",
        "due_date": "May 30, 2024",
        "site": {
          "name": "Site A",
          "location": "A"
        },
        "department": {
          "name": "Finance"
        },
        "state": "draft",
        "requester": {
          "email": "guy.frieman@solarwinds.com"
        },
        "recurrence": "Monthly",
        "total_cost": "1",
        "currency": "USD",
        "tax": "1",
        "notes": "Purchase notes",
        "vendor": {
          "name": "google"
        },
        "billing_address": "Billing address",
        "shipping_address": "Shipping address",
        "payment_terms": "Purchase terms",
        "terms_conditions": "Terms conditions",
        "approval_levels_attributes": [
          {
            "approver_ids": "7142201",
            "approval_condition": "1",
            "level": "1"
          },
          {
            "approver_ids": "7142035",
            "approval_condition": "2",
            "level": "2"
          }
        ]
      }
    }

    We will make sure to add it to the API docs .
  • Hey 
    You can create the Purchase Order with multiple Approvals level with the API using the level.

    You need to  add level  part of the approval_levels_attributes
    Here is an example of a request 
    You need to modify the values according to the relevant data.
    {
      "purchase_order": {
        "name": "test 222222344",
        "buyer_id": "272751",
        "buyer": {
          "email": "guy.fr@solarwinds.com"
        },
        "order_date": "May 30, 2023",
        "due_date": "May 30, 2024",
        "site": {
          "name": "Site A",
          "location": "A"
        },
        "department": {
          "name": "Finance"
        },
        "state": "draft",
        "requester": {
          "email": "guy.frieman@solarwinds.com"
        },
        "recurrence": "Monthly",
        "total_cost": "1",
        "currency": "USD",
        "tax": "1",
        "notes": "Purchase notes",
        "vendor": {
          "name": "google"
        },
        "billing_address": "Billing address",
        "shipping_address": "Shipping address",
        "payment_terms": "Purchase terms",
        "terms_conditions": "Terms conditions",
        "approval_levels_attributes": [
          {
            "approver_ids": "7142201",
            "approval_condition": "1",
            "level": "1"
          },
          {
            "approver_ids": "7142035",
            "approval_condition": "2",
            "level": "2"
          }
        ]
      }
    }

    We will make sure to add it to the API docs .
  • Hi Rinat, that worked perfectly for the approval levels! Thank you!

    Having multiple approvers doesn't seem to work though. I thought that was a side effect of the approval level issue I was having, but it seems like only the first ID in the "approver_ids" string gets accepted. Not sure if you have any ideas?

    My submitted payload results in only the 9202161 group on the 2nd level approval.





  • Hi Rinat! Following back up on this because I forgot to at-mention you in my last question. 

  • Hi Rinat, that worked perfectly for the approval levels, but opens up a second question:

    Having multiple approvers doesn't seem to work as documented. I thought that was a side effect of the approval level issue I was having, but it seems like only the first ID in the "approver_ids" string gets accepted. Not sure if you have any ideas?

    My submitted payload results in only the 9202161 group ending up on the 2nd level approval.