【问题标题】:How do I return a list from a custom object in Salesforce using javascript on a button?如何使用按钮上的 javascript 从 Salesforce 中的自定义对象返回列表?
【发布时间】:2016-03-11 23:27:20
【问题描述】:

我在 Salesforce 中有一个名为 Website_Role__c 的自定义对象。此对象包含与具有不同角色(所有者、导师等)的商店相关联的人员列表。

在帐户上的 Salesforce 按钮中使用 JavaScript:

所需的行为是用户单击按钮并弹出一个对话框,其中包含该帐户的 Website_Role__c 中的人员列表。每个人旁边都会有一个复选框,允许用户选择他们。

我们正在使用 eSign(以前称为 EchoSign)。此按钮是“使用电子签名发送”按钮,用于将协议发送到来自 Website_Role__c 的人员列表。

这就是我现在的位置:

/*My Attempt*/
{
    !REQUIRESCRIPT("/soap/ajax/19.0/connection.js")
} //adds the proper code for inclusion of AJAX toolkit
var url = parent.location.href; //string for the URL of the current page
var records = {!GETRECORDIDS($ObjectType.Website_Role__c)
}; //grabs the Website Role records for the currently selected store
var updateRecords = []; //array for holding records that this code will ultimately update

if (records[0] == null) { //if the button was clicked but there was no record selected
    alert("Please select at least one person to send to."); //alert the user that they didn't make a selection 
} else { //otherwise, there was a person selected
    for (var a = 0; a < records.length; a++) { //for all records
        var update_Website_Role__c = new sforce.SObject("Website_Role__c"); //create a new sObject for storing updated record details
//This is where I get lost. Not sure if this is even the correct approach
    }
//??
    parent.location.href = url; //refresh the page
}

如果您能提供任何帮助,我将不胜感激。 谢谢

【问题讨论】:

    标签: javascript salesforce


    【解决方案1】:

    试试这样的:

    {!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
    
    var query = sforce.connection.query("SELECT Owner__c, Mentor__c FROM Website_Role__c WHERE Account__c ='{!Account.Id}'");
    var records = query.getArray("records");
    
    alert("Owner is: " + records[0].Owner__c);
    

    这假定您的 Website_Role 对象上有一个指向帐户的引用字段。 在这里查看更多示例 https://developer.salesforce.com/docs/atlas.en-us.ajax.meta/ajax/sforce_api_ajax_more_samples.htm

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-07
      • 2016-02-17
      • 2015-08-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多