我正在使用Veeva CRM,试图使用点击流跟踪。我有正在使用的代码,试图跟踪Presentation id,产品密钥消息,跟踪元素描述和答案。

任何人都可以帮助我使用的代码。
谢谢

<!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>





我也有一些示例代码可以尝试,但不确定我在做什么错。
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));
}

最佳答案

不知道您是否仍然需要帮助。但是我的团队在每个项目中都使用了一种简单的方法来简化跟踪过程。修改了以下内容,以适合您的某些命名约定/需要。

// 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 );
}

只需调用该方法并传入您的参数,包括回调方法即可。

希望这可以帮助!

09-25 19:56