Update Appointment Preferences

Purpose

To update the appointment preferences in your organization.

Request Details

Request URL

{api-domain}/crm/{version}/settings/appointment_preferences

Header

Authorization: Zoho-oauthtoken d92d4xxxxxxxxxxxxx15f52

Scope

scope=ZohoCRM.settings.modules.{operation_type}

Possible operation types

ALL - Full access to appointment preferences data
UPDATE - Update appointment preferences

Sample Request

Copiedcurl "https://www.zohoapis.com/crm/v6/settings/appointment_preferences"
-X PUT
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"

Request JSON Keys

  • allow_booking_outside_service_availabilityBoolean, optional

    Denotes if you can create appointments outside service availability.
    Possible Values:
    true: You can create appointments outside service availability.
    false: You cannot create appointments outside service availability.

  • allow_booking_outside_businesshoursBoolean, optional

    Denotes if you can create appointments outside business hours. You can configure this preference only when allow_booking_outside_service_availability:true.
    Possible Values:
    true: You can create appointments outside business hours.
    false: You cannot create appointments outside business hours.

  • when_duration_exceedsString, optional

    Represents who has to mark the appointment as 'Completed' when the service duration gets over.
    Possible Values:
    ask_appointment_provider_to_complete - User have to manually mark the appointment as 'completed'.
    mark_as_complete - The appointment is automatically marked as 'completed'.

  • show_job_sheetBoolean, optional

    Represents whether filling out the job sheet is mandatory for marking an appointment as 'completed'. You can mandate job sheets only when when_duration_exceeds: ask_appointment_provider_to_complete .
    Possible Values:
    true: Job sheet is mandatory for appointment completion.
    false: Job sheet is not mandatory for appointment completion.

  • when_appointment_completedString, optional

    Represents whether a deal has to be created, when an appointment is completed.
    Possible Values:
    create_deal - Deal is created when any appointment is marked 'Completed'.
    do_not_create_deal - Deal is not created when any appointment is marked 'Completed'.

  • deal_record_configurationJSON object, mandatory for deal creation

    Contains the field mappings and layout details for record configuration in the Deals from Appointments module. The key is mandatory when when_appointment_completed:create_deal.

    • layout (JSON object, mandatory) - Contains the Deals layout ID and name of the layout to which you want to map the appointment fields. You can get these details from Layouts Metadata API.
    • field_mappings (JSON array, mandatory) - Contain the fields from Deals module which have to be mapped with Appointments and Services module fields to create deals automatically when an application is completed. This field mapping is bounded to the specified layout and you have to create a new field mapping for different layouts. Deal_Name, Account_Name, Closing_Date, Pipeline and Stage fields are mandatory for field_mappings.
      • field (JSON object, mandatory) - Represents the API name and ID of the field present in the Deals module that you want to fill in using the data from the Appointments module. Refer to the Fields Metadata API to get the list of fields available in a module. Ensure that you do not feed an invalid field API name or the ID as it will throw an error.
      • type (string, mandatory) - The Deals field can either be merged with the Appointments field or made a static field.
        Possible Values:
        merge_field - The Appointments field values are mapped to the Deals field values.
        static - The values given in this type are standard for all the deals.
      • value (string, mandatory) - Denotes the value of the Deals fields. The value is different for each specified type.
        Value for merge_field: The datatype of this value is a string. To merge any field from a module, it should be specified like this ${module_api_name.field_api_name}.
        Example: ${Appointments__s.Appointment_Name}
        Value for static: The datatype of this value is a JSON object. It contains the name and ID of the entity.
        When you want to give static values that look up to a different module, make a GET API call of the specific module and provide the relevant ID and name of the record. You can also give standard text values enclosed in a string.

Note

  • The system-defined field mappings are specified below. This mapping cannot be changed and it is a read-only field.
    • Amount - The amount field in the Deals module is mapped with the Price field in the Services module.
    • Closing_Date - The closing date field in the Deals module is mapped with the Appointment_Start_Time field in the Appointments module.
  • "when_duration_exceeds":"ask_appointment_provider_to_complete" is the default Appointment preference for any organization.
  • A few fields are given default field mappings and are listed below.
    • Owner - Super admin of the organization.
    • currency - The configured home currency of your organization.
    • Pipeline - The standard pipeline of the specified layout.
    • Deal_Name - The Appointment_Name field in the Appointments module.
  • The type of 'Owner' field is static only when you choose either Super Admin or Users from the picklist. The type should be merge_field for 'Member', 'Appointment created by' and 'Appointment modified by' picklist values.

Sample Input

Copied{
    "appointment_preferences": {
        "allow_booking_outside_businesshours": false,
        "deal_record_configuration": {
            "layout": {
                "name": "Standard",
                "id": "5545974000000091023"
            },
            "field_mappings": [
                {
                    "field": {
                        "api_name": "Owner",
                        "id": "5545974000000002555"
                    },
                    "type": "static",
                    "value": {
                        "name": "James Smith",
                        "id": "5545974000001170042"
                    }
                },
                {
                    "field": {
                        "api_name": "Deal_Name",
                        "id": "5545974000000002559"
                    },
                    "type": "merge_field",
                    "value": "${!Appointments__s.Appointment_Name}"
                },
                {
                    "field": {
                        "api_name": "Account_Name",
                        "id": "5545974000000002563"
                    },
                    "type": "static",
                    "value": {
                        "name": "Printing Dimensions",
                        "id": "5545974000000407008"
                    }
                },
                {
                    "field": {
                        "api_name": "Stage",
                        "id": "5545974000000002565"
                    },
                    "type": "static",
                    "value": "Closed Won"
                },
                {
                    "field": {
                        "api_name": "currency",
                        "id": "5545974000000050013"
                    },
                    "type": "static",
                    "value": {
                        "name": "SAR",
                        "id": "5545974000000407008"
                    }
                },
                {
                    "field": {
                        "api_name": "Pipeline",
                        "id": "5545974000000193001"
                    },
                    "type": "static",
                    "value": {
                        "name": "Service Pipeline",
                        "id": "5545974000000407008"
                    }
                }
            ]
        },
        "show_job_sheet": true,
        "when_duration_exceeds": "ask_appointment_provider_to_complete",
        "when_appointment_completed": "create_deal",
        "allow_booking_outside_service_availability": false
    }
}

Possible Errors

INVALID_DATAHTTP 400

You have given an invalid field ID for field key.
Solution: Make a GET Fields Metadata API call and provide a valid field ID.

  • API_NOT_SUPPORTEDHTTP 400

    The API is not supported in this version.
    Solution: This API is supported only from Version 3.

  • DEPENDENT_FIELD_MISSINGHTTP 400

    You have specified the layout ID but not the field_mappings.
    Solution: You have to configure a new field mapping, whenever you change the layout ID of the Deals module.

  • DEPENDENT_FIELD_MISSINGHTTP 400

    You have given null for the deal_record_configuration key.
    Solution: The deal_record_configuration key cannot be null if the when_appointment_completed key is given create_deal value.

  • DEPENDENT_MISMATCHHTTP 400

    You have tried to enable the allow_booking_outside_businesshours key without enabling the allow_booking_outside_service_availability key.
    Solution: The "allow_booking_outside_service_availability": true is mandatory to enable the allow_booking_outside_businesshours key.

  • DEPENDENT_MISMATCHHTTP 400

    You are trying to mandate job sheets without specifying the ask_appointment_provider_to_complete value.
    Solution: The when_duration_exceeds key must be given ask_appointment_provider_to_complete value to mandate job sheets in the appointment preferences.

  • INVALID_DATAHTTP 400

    You have mapped two different datatype fields in the fields_mappings key.
    Solution: You can only map similar datatype fields in the field_mappings for deal record configuration.

  • INVALID_DATAHTTP 400

    You have specified an invalid value for either when_appointment_completed key or when_duration_exceeds key.
    Solution: Possible values for when_appointment_completed key: 'create_deal' and 'do_not_create_deal'.
    Possible values for when_duration_exceeds key: 'ask_appointment_provider_to_complete' and 'mark_as_complete'.

  • INVALID_DATAHTTP 400

    You have specified an invalid value for the type key in the field mappings.
    Solution: The only possible values are 'merge_field' and 'static'.

  • INVALID_DATAHTTP 400

    You have mandated job sheets without enabling Job Sheets in the Service Preferences.
    Solution: You cannot mandate job sheets, if they are not enabled for services. Make an Update Service Preferences API call to enable job sheets for services.

  • INVALID_DATAHTTP 400

    You have given an invalid layout ID.
    Solution: Make a GET Layouts API call and provide a valid layout ID.

  • INVALID_DATAHTTP 400

    You have specified Date or DateTime or Unique field value for static type in field_mappings.
    Solution: Date, DateTime and Unique fields are not supported in static type. Use merge_field type.

  • INVALID_MAPPINGHTTP 400

    You have specified a value with length greater than the Deals field length.
    Solution: In static type, the length of the value should be less than or equal to the maximum length of the Deals field.

  • INVALID_REQUEST_METHODHTTP 400

    You have given an invalid http request method type.
    Solution: Use only the PUT method in the request input to access this API.

  • MAPPING_MISMATCHHTTP 400

    You have specified a different pipeline which is not present in the layout.
    Solution: Make a GET Pipelines API call with the correct layout ID which is mentioned in the request body.

  • MAPPING_MISMATCHHTTP 400

    You specified a stage which is not in the given pipeline.
    Solution: Make a GET Pipelines API call and provide a valid stage.

  • REQUIRED_DATA_NOT_FOUNDHTTP 400

    You failed to map the mandatory fields in the deal_record_configuration key.
    Solution: Deal Name, Account Name, Closing Date, Pipeline and Stage fields are mandatory for field mappings in the deal_record_configuration key.

  • INVALID_TOKENHTTP 401

    You have used an invalid oauth token.
    Solution: The access token you used has expired. Kindly refresh your token and retry.

  • OAUTH_SCOPE_MISMATCHHTTP 401

    You created the grant token using the wrong oauth scope.
    Solution: Use either ZohoCRM.settings.modules.UPDATE or ZohoCRM.settings.modules.ALL scope to create a new valid grant token.

  • NO_PERMISSIONHTTP 403

    You do not have permission to update the appointment preferences.
    Solution: Contact your system administrator.

  • NOT_ALLOWEDHTTP 403

    You have tried to map either the Closing_Date or Amount key with a different field.
    Solution: The Closing_Date and Amount key have system-defined field mappings with Appointment_Start_Time and Price fields respectively. You cannot remap them to different fields.

  • NOT_ALLOWEDHTTP 403

    You have tried to specify a new stage in the pipeline.
    Solution: Only closed won stages are allowed to map with the Stage field.

  • NOT_ALLOWEDHTTP 403

    You have tried to remove either the Amount or Closing_Date field from the deal_record_configuration key.
    Solution: The Amount and Closing_Date field mapping cannot be removed.

  • INTERNAL_ERRORHTTP 500

    Internal Server Error
    Solution: Unexpected and unhandled exception in the server. Please contact our support team.

Sample Response

Copied{
    "appointment_preferences": {
        "code": "SUCCESS",
        "details": {},
        "message": "Appointments preferences updated successfully",
        "status": "success"
    }
}