This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Is It Possible to Update a User's Custom Fields Via the API?

Hi All,

I'm trying to automate some user updates via that Solar Winds Service Desk (formerly SAManage) API. We're have a custom field for every user called "empid" - a unique ID per user that's separate from the one the Service Desk generates. Some users are lacking this value and we want to backfill them, so I'm writing code that hits a separate DB, gets their empid, and then updates their Service Desk profile. The problem is, I cannot manage to get the value to show up for users with no existing empid OR change for users with an existing empid that's incorrect. I can change anything else in the user object, but have not been able to get custom fields to change.

I did some research and it appears there's still work being done on the custom fields API but I can't quite tell if that's just for creating NEW custom fields (which we're not trying to do) or for updating them on users, tickets, etc.

I've tried every format I could think of to update the user's custom field, to no avail. Some examples:

updatedUser.custom_fields_values = [
  {
    name: 'Empid',
    value: 12345,
  },
];
and
updatedUser.custom_fields_values = {
  custom_fields_value: [
    {
      name: 'Empid',
      value: 12345,
    },
  ],
};

and
updatedUser.custom_fields_values = {
  custom_fields_value: [
    {
      attachment: null,
      custom_field_id: 4257891,
      entity: null,
      id: 230146872,
      name: 'Empid',
      options: '',
      type: 1,
      type_name: 'Text',
      user: null,
      value: 12345,
    },
  ],
};
With no luck. I'm unsure if it's a formatting issue or if the API's just not set up to do this yet. Any info would be appreciated.
Thanks!
-Chris

  • We used to be able to update the custom fields via API. For some reason, it stopped working between July 21st-July 27th

    I have an open ticket with Samanage since July 27th. The only update I have is "Our Product Team is looking into this, but we cannot provide an ETA yet. Please let me know if you have questions or clarifications."

    We have been using this API call to help us manage user lifecycle functions for the last year

  • Thank you for the info! Sorry you're having trouble too but good to hear I'm not the only one. I was considering submitting a service request but it sounds like that's not going to be of much use either.

  • We use the API heavily and haven't seen any issues with updating custom fields on user records.  I definitely would recommend submitting a service request if you're still having issues.  I just tested updating my own user through Postman with the following json and it successfully changed.

    {
        "user": {
            "custom_fields_values": {
                "custom_fields_value": [
                    {
                        "name": "EmployeeId",
                        "value": "00"
                    }
                ]
            }
        }
    }

    One thing I noticed is that you seem to have some dangling commas where there shouldn't be if this is being submitted as json.  That often blows up the API request due to an invalid format.  If you removed those extra commas so it looks more like this, does it work?

    updatedUser.custom_fields_values = {
      custom_fields_value: [
        {
          name: 'Empid',
          value: 12345,
        }
      ]
    };
  • Unfortunately that doesn't change anything - that's just JavaScript code, which has trailing commas. It gets stringified into properly formatted JSON before submitting to SAManage.

    HOWEVER, I did determine the issue!

    I was sending data that looked like this:

    {
      "id": 267194,
      "name": "redacted",
      "email": "redacted@holycross.edu",
      "phone": "redacted",
      "mobile_phone": "redacted",
      "custom_fields_values": {
        "custom_fields_value": [
          {
            "name": "Empid",
            "value": "1234567"
          }
        ]
      }
    }
    When I needed to be sending data that looks like this:
    {
    "user": {
        "id": 267194,
        "name": "redacted",
        "email": "redacted@holycross.edu",
        "phone": "redacted",
        "mobile_phone": "redacted",
        "custom_fields_values": {
          "custom_fields_value": [
            {
              "name": "Empid",
              "value": "1234567"
            }
          ]
        }
      }
    }
    That top-level "user" object is essential.
    What's weird and was confusing me is: I can update fields like name and email WITHOUT the top level user object. So I didn't realize I was missing it in my code, because my updates to everything EXCEPT the custom fields were going through without a problem.
    Anyway, working now!