Loading
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          createVisit Function

          createVisit Function

          Creates a visit for the selected attendees and returns the result to the specified callback method. Salesforce applies all configured visit validations to the created visit.

          Required Editions

          Available in: Lightning Experience
          Available in: Enterprise and Unlimited Editions with Life Sciences Cloud, Life Sciences Cloud for Customer Engagement Add-on license, and the Life Sciences Customer Engagement managed package.
          Tip
          Tip We recommend invoking this function only one time per presentation session.

          Syntax

          PresentationPlayer.createVisit(callbackMethod)

          Arguments

          Argument Description
          callbackMethod The name of the JavaScript method that receives the results of the operation.

          Returns

          This method returns JSON that contains the ID of the parent visit, for example:

          {"state":"success", "id": "<parent_visit_uid>"}

          Usage

          When this function is called during a presentation and a visit is created successfully:

          • Users can select the Visit button in the presentation player menu to open the visit. All presentation metrics that are tracked during the session are linked to the visit.
          • If no attendees were selected before the visit was created, the account field on the visit is blank.
          • Product restrictions and presentation targeting apply to the new visit.
          • These records are related to the new visit.
            • Provider visit
            • Provider visit product detailing
            • Provider visit detailing product message
            • Presentation forum
            • Presentation click stream entry

          Limitations

          • The createVisit function doesn’t populate the new visit’s details into Mustache variables that reference visits.
          • Don’t use the upsert function to create visits.

          Example

          <body>
                        <input id="name" style="color: black;">
                        <input id="customField" style="color: black;">
                        <a href="javascript:createVisit();">Create Visit</a>
                </body>
                <script type="text/javascript">
                        function createVisit() {
                                PresentationPlayer.createVisit('callbackMethod');
                        }
                        function callbackMethod(data) {
                                console.log(data);
                                PresentationPlayer.alert(JSON.stringify(data));
                        }
                </script>

          Errors

          This function returns errors when:

          • Validation rules fail.
          • A visit was already created during the presentation session. In this case, the function returns the ID of the visit that was created previously in JSON format.
          • The presentation player is opened for an existing visit. In this case, the function returns the ID of the visit that was created previously in JSON format.
          • The presentation player is opened in a context that’s unrelated to the visit.

          This example is an error result in JSON format.

          {"state":"error", "errorMessage": "<error>", "id": "<optional_id_of_previously_created_visit>"}
           
          Loading
          Salesforce Help | Article