• Share
    • Twitter
    • LinkedIn
    • Facebook
    • Email
  • Feedback
  • Edit
Show / Hide Table of Contents

How to delete a user-defined field using the web services API

Audience:
api
Some tooltip text!
• 3 minutes to read
 • 3 minutes to read

This guide describes how to delete a user-defined field using the web services API.

Steps

The following REST code snippets use plain http requests to demonstrate how to perform the operation. The WebApi code snippet demonstrates how to perform the same operation using our nuget package SuperOffice.WebApi.

  • RESTful REST API
  • HTTP RPC Agent API
  • SuperOffice.WebApi

Describes how-to delete a Contact user-defined field details by prog-id or label. This deletes the admin version of the field. The layout needs to be published before the change is visible.

  1. Delete the user-defined field:

    Delete by ProgId

    DELETE https://{{env}}.superoffice.com/{{tenant}}/api/v1/Contact/UdefLayout/SuperOffice:11
    Authorization: Bearer {{token}}
    Accept: application/json; charset=utf-8
    

    Delete by FieldLabel

    DELETE https://{{env}}.superoffice.com/{{tenant}}/api/v1/Contact/UdefLayout/My New Number
    Authorization: Bearer {{token}}
    Accept: application/json; charset=utf-8
    
  2. Make sure the Contact user-defined fields are not currently being updated.

    GET https://{{env}}.superoffice.com/{{tenant}}/api/v1/Contact/UdefLayout/Publish HTTP/1.1
    Authorization: Bearer {{token}}
    Accept: application/json; charset=utf-8
    

    Only if the response is False, proceed to publish and complete the delete operation.

  3. Publish to finalize the delete changes.

    POST https://{{env}}.superoffice.com/{{tenant}}/api/v1/Contact/UdefLayout/Publish HTTP/1.1
    Authorization: Bearer {{token}}
    Accept: application/json; charset=utf-8
    

Get the current UDefFieldId value for the user-defined field to delete, then pass that into the following request as a query string parameter.

  1. Deletes the user-defined field is 868.

    POST https://{{env}}.superoffice.com/{{tenant}}/api/v1/Agents/UserDefinedFieldInfo/DeleteUserDefinedFieldInfo?UserDefinedFieldInfoId=868 HTTP/1.1
    Authorization: Bearer {{token}}
    Accept: application/json; charset=utf-8
    
  2. Publish to complete the delete operation for this user-defined field.

    Warning

    A Publish request creates a new version of all user-defined fields for the entity. Therefore, all user-defined fields not deleted will have updated UdefFieldId values. Before published fields, make sure there is no active publish event happening at the same time. As long as the IsAnyPublishEventActive call returns false, it is safe to proceed.

    POST https://{{env}}.superoffice.com/{{tenant}}/api/v1/Agents/UserDefinedFieldInfo/IsAnyPublishEventActive
    Authorization: Bearer {{token}}
    Accept: application/json; charset=utf-8
    

    To prevent anyone from overwriting your field changes, set the publish event flag for the entity.

    POST https://{{env}}.superoffice.com/{{tenant}}/api/v1/Agents/UserDefinedFieldInfo/SetPublishStartSystemEvent
    Authorization: Bearer {{token}}
    Accept: application/json; charset=utf-8
    Content-Type: application/json; charset=utf-8
    {
        "OwnerType": "Contact"
    }
    

    Finally issue the publish the request to activate the new field changes.

    POST https://{{env}}.superoffice.com/{{tenant}}/api/v1/Agents/UserDefinedFieldInfo/Publish
    Authorization: Bearer {{token}}
    Accept: application/json; charset=utf-8
    Content-Type: application/json; charset=utf-8
    {
        "OwnerType": "Contact"
    }
    
Note

Depending on the user-case it might be a good idea to flush caches.

In This Article
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top