本文介绍了通过Update- Salesforce C#将链接保存在自定义对象中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码,该代码在Salesforce中创建一个Task,然后跟踪用户的浏览历史记录并将其存储在SalesForce中.当前,它显示用户浏览过的每个页面作为一个单独的条目.我想将所有这些条目分组 一起放在Browsing_History__c对象中,而不是每次用户访问页面时都创建任务.我需要修改查询并将其附加到该对象,但不确定如何处理.

I have the following code which creates a Task in Salesforce and then tracks a user's browsing history and stores it in SalesForce. Currently, it displays each and every page the user has browsed as an individual entry. I want to group all those entries together in the Browsing_History__c object instead of task being created every time a user visits a page. I need to modify the query and append it to that object but not sure how to go about it.

任何帮助将不胜感激..我对SF不太熟悉. :)

 Any help would be appreciated..I am not familiar with SF very much. :)

 

private void CreateTaskInSF(string id, string type, string details, string description)
  {
   // if there's a similar Event in the past 2 hours, don't add it
   QueryResult qr = null;
   try // get events from past 2 hours
   {
    qr = Binding.query("Select Details__c from Task WHERE WhoId='" + id + "' and Type__c='" + type + "' and CreatedDate > " + DateTime.UtcNow.AddHours(-2).ToString("s") + "Z");
   }
   catch (Exception e)
   {
    return;
   }
   bool logged = false;
   if (qr != null) // if there are Tasks in past 2 hours
   {
    sforce.sObject[] browsing = qr.records;
    if (browsing != null)
    {
     // iterate through events to make sure the new Task isn't logged
     for (int i = 0; i < browsing.Length; i++)
     {
      Task currTask = (Task)browsing[i];
      if (currTask.Details__c == details)
      {
       if (description != "") // is there a description to check for?
       {
        string oldTaskDescription = "";
        if (currTask.Description != null)
         oldTaskDescription = currTask.Description;
        if (oldTaskDescription == description) // if there is a description match
         logged = true;
       }
       else
        logged = true; // there's no description, so check only on details field
      }
     }
    }
   }
   if (logged == true)
   {
    return; // if Activity is already logged, don't log it again
   }

   else if (type == "Browsing")
   {

     Web_Browsing__c newTask = new Web_Browsing__c();
     newTask.Lead__c = id;
     newTask.Browsing_History_255__c = details;
     newTask.Type__c = type;

     newTask.Browsing_History__c = details;
     newTask.CreatedDate = DateTime.Now;
     try
     {
      SaveResult[] createResult = Binding.create(new sObject[] { newTask });
     }
     catch (Exception e)
     {
      return;
     }

   }

   else
   {
    // if this new Activity isn't logged, then create a new Activity Task
    sforce.Task newTask = new sforce.Task();
    newTask.WhoId = id;
    newTask.Subject = type;
    newTask.Details__c = details;
    if (description != "") newTask.Description = description;
    newTask.Status = "Completed";
    newTask.Priority = "Normal";
    newTask.ActivityDate = DateTime.Now;
    newTask.ActivityDateSpecified = true;

    // insert it
    try
    {
     SaveResult[] createResult = Binding.create(new sforce.sObject[] { newTask });

    }
    catch (Exception e)
    {
     return;
    }
   }


  }

推荐答案


这篇关于通过Update- Salesforce C#将链接保存在自定义对象中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 13:36