Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Salesforce by (11.9k points)

I am working with Veeva CRM, trying to use Click Stream Tracking. I have the code which I am using and trying to track the Presentation id, Product Key Message, track an Element Description and Answer.

Can anybody help with the code that I am using? Thanks

<!DOCTYPE html> 

<html lang="en"> 

  <head> 

   <meta charset="utf-8"> 

     <meta http-equiv="X-UA-Compatible" content="IE=edge"> 

   <meta name="viewport" content="width=device-width, initial-scale=1"> 

   <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> 

  <title>CLM_CERT_HCPName</title> 

  <!-- Bootstrap --> 

 <link href="css/style.css" rel="stylesheet"> 

 <link href="css/animate.css" rel="stylesheet"> 

 <script src="js/veeva-library-3.0.js"></script> 

  <script> 

    function start(){ 

     header_getAccountName(); 

    } 

  function header_getAccountName(){    com.veeva.clm.getDataForCurrentObject("Account","Name",header_displayAccountName)} 

 function header_displayAccountName(result){ 

var AccountNameHTML = document.getElementById("hcpName"); 

AccountNameHTML.innerHTML += result.Account.Name;com.veeva.clm.getDataForCurrentObject("Presentation","Survey_vod__c",header_getSurveyID); 

function mySaveObject(){ 

//This is the start of my JSON object 

var myCallClickStream = {Call_vod__c, Key_Message_vod__c}; 

//i am using my JSON obj name with the field API name of the call clickstream     object obj.apiName then set the value. obj.apiName= value;] 

// Create the record using the com.veeva.clm.createRecord 

com.veeva.clm.createRecord("Call_ClickStream_vod_c", myCallClickStream, printSavedResults)}

function printSavedResults(result){ 

alert(JSON.stingify(result)); 

</script> 

</head> 

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> 

I have also some sample code to try out but not sure what I am doing wrong.

function mySaveObject(){

var myCallClickStream = {};

myCallClickStream.Text_Entered_vod__c = "i will put some text here";

com.veeva.clm.createRecord("Call_Clickstream_vod__c", myCallClickStream, printSavedResults)

}

function printSavedResults(result) {

alert(JSON.stringify(result));

}

1 Answer

0 votes
by (32.1k points)
edited by

Not sure if you still need help on this or not. But my team uses a simple method in every project to simplify the tracking process. The below was modified to fit some of your naming conventions/needs.

// clmDescription - string submitted as the description to be tracked

// clmAnswer - string submitted as the answer to be tracked`

// callback - call back function which will be used to return the information

function mySaveObject( clmDescription, clmAnswer, clmCallback ) {

    var url = window.location.pathname,

        filename = url.substring(url.lastIndexOf('/') + 1),

        clmTrackingID = filename.replace(".html", "");

    var myCallClickStream = {};

    myCallClickStream.Track_Element_Id_vod__c = clmTrackingID;

    myCallClickStream.Track_Element_Type_vod__c = clmDescription;

    myCallClickStream.Selected_Items_vod__c = clmAnswer;

    myCallClickStream.Track_Element_Description_vod__c = clmAnswer;

    // var myJSONText = JSON.stringify( myCallClickStream );

    com.veeva.clm.createRecord( Call_Clickstream_vod__c, myCallClickStream, clmCallback );

}

Simply call the method and pass in your parameters, including your callback method.

Hope this helps!

To learn in-depth about Workflow in Salesforce, sign up for industry-based Salesforce Training!

Related questions

Browse Categories

...