Showing results for 
Search instead for 
Did you mean: 

Assign a Survey to Visit using c4codata API

0 Kudos

Hello, I'm trying to use the c4codata API to create a Visit, attach a Survey, start the Visit, and update values. However I'm running into issues with attaching the Survey.

Here's what it looks like from the UI:


With the API, those surveys are VisitWorklistItems as described here: However those objects can't be created, so I'd like to know this can be done.



For more info on what I've done so far, I'm creating a visit with a POST to 




 I can then see there are WorkItems already created for the Visit by making a GET to


activity/VisitWorklistItemCollection?$filter=ParentObjectID eq '<parent_id>'


Comparing the differences between a visit with a survey assigned and one without, the only difference is with the value of ExecutedIndicator. However if I try to update that using a PATCH to




with the payload


    "ExecutedIndicator": true


It returns


    "error": {
        "code": "CX_ODATA_ANNOTATION_ERROR",
        "message": {
            "lang": "en",
            "value": "Update not allowed for properties: ExecutedIndicator. Check metadata for VisitWorklistItemCollection"


 Looking at the docs here:, it seems like it should be editable:


However in the $metadata it doesn't, which seems to be the behaviour:


<EntityType Name="VisitWorklistItem">
    <Property Name="ExecutedIndicator" Type="Edm.Boolean" Nullable="true" sap:creatable="false" sap:updatable="false" sap:filterable="true"/>


View Entire Topic
0 Kudos

What ended up working was going Activity Planning > Routing Rules and setting up an Activity Plan that included the survey, and setting it to be assigned automatically.

This seems to be a batch process that runs periodically rather than something that happens as part of the visit being created, I found it can take a couple minutes for the survey to actually show up.

When creating the visit programatically I wait for the survey to be assigned by querying the following endpoint with a filter for the visit:

surveyresponse/SurveyResponseCollection?$filter=BusinessTransactionDocumentUUID eq '<visitObjectId>'

For some reason if the survey response doesn't exist and the filter doesn't match it just returns everything, whereas if it does it returns one.