iframe问题:Salesforce未在SOQL嵌套查询中获取父级

时间:2016-11-28 12:19:45

标签: salesforce apex-code visualforce apex salesforce-communities

情况:嗨我有一个查询功能正常&按照salesforce vf页面中的预期。

问题从iframe调用时,它返回没有父对象的输出。

顶点中的代码:

< apex:page controller="myValues" >

< apex:pageBlock title="{!xx}" >

< /apex:pageBlock >

< /apex:page >

VF中的代码

{"attributes":{"type":"CKSW_BASE__Service__c","url":"/services/data/v38.0/sobjects/CKSW_BASE__Service__c/sss"},"Id":"s","Name":"S","Service_Status_History__r":{"totalSize":6,"done":true,"records":[{"attributes":{"type":"Service_Status_History__c","url":"/services/data/v38.0/sobjects/Service_Status_History__c/ss"},"Service__c":"asss","Id":"uu","Name":"yyy","Previous_Status__c":"xyz","New_Status__c":"y","Reason_Code__c":"xyz","Comment__c":"abc"}]}
  

Salesforce的输出

     

{{1}}

  

iframe输出

     

{ “属性”:{ “类型”: “CKSW_BASE__Service__c”, “URL”: “/服务/数据/ v38.0 / sobjects / CKSW_BASE__Service__c / 444”}, “ID”: “444”, “名称” : “XYZ”}

Vf页面中,我获得了具有全部值的所需输出,但是来自我的force.com网址中的 iframe,父对象(嵌套查询)不可用

但是,当我仅使用简单的专用查询调用父时,会在中返回值(iframe和url) )地方。

为什么我的嵌套SOQL无法获得父母的对象。我在这里失踪了什么?

提前致谢。 请帮忙。

Iframe的输出

2 个答案:

答案 0 :(得分:0)

你检查过你的FLS吗?

  

构建 - &gt;开发 - &gt;网站 - &gt; - &GT;公共访问设置

这是Force.com结果大部分时间的罪魁祸首。

答案 1 :(得分:0)

  
    

是的我已经检查过,它授予了公共访问权限。甚至我能够     在转换和以JSON格式打印时看到它们。但我无法看到     如果用解析对象形式打印,它们在iframe中。

  
     

因此,通过以Json字符串格式发送值并通过它,它对我有用   在那边解析它。

在Vf页面

<apex:page Controller="showServiceHistory" sidebar="false" showheader="false">
<html>
    <head>
    <!--<meta http-equiv="refresh" content="20" ></meta> -->

</head>
<a id="history_data" style="display:none;">{!history}</a>
<a id="service_data" style="display:none">{!service}</a>
<style>
    table {
        width: 100%;
    }

    table,
    th,
    td {
        border-collapse: collapse;
        color: #3088D0;
    }

    th,
    td {
        padding: 5px;
        text-align: left;
        color: #1F497D;
    }

    tr {
        //color: #337AB7;
    }

    table#t01 tr:nth-child(even) {
        background-color: #DCE6F1;
        //color: #337AB7;
    }

    table#t01 tr:nth-child(odd) {
        background-color: #fff;
    }

    table#t01 th {
        background-color: #B8CCE4;
        //color: #000015;
    }

    a:link {
        color: #62B3E2;
    }

    a:visited {
        color: #62B3E2;
    }
</style>


<table id="t01">
    <thead>
        <tr>
            <th>
                Name
            </th>

            <th>
                Previous Status
            </th>
            <th>
                New Status
            </th>
            <th>
                Comment
            </th>
        </tr>
    </thead>
    <tbody id="show_values">
    </tbody>

</table>
<script>
    function x()
    {
    var history={}; var service={};
    history=JSON.parse(document.getElementById("history_data").innerHTML); 
    service=JSON.parse(document.getElementById("service_data").innerHTML); 
    var show='';
        for(var i=0;i<history.length;i++)
        {
           show=show+'<tr><td>'+history[i].Name+'</td><td>'+history[i].Previous_Status__c+'</td><td>'+history[i].New_Status__c+'</td><td>'+history[i].Comment__c+'</td><td>'+service.CKSW_BASE__Location__c+'</td></tr>';
        }
            document.getElementById("show_values").innerHTML=document.getElementById("show_values").innerHTML+show;
    }
    x();
</script>
</html>

在顶级代码页

public class showServiceHistory {
List<Service_Status_History__c> histories;
String x;
CKSW_BASE__Service__c services;
String id = ApexPages.currentPage().getParameters().get('id');
 public showServiceHistory()
{
    services = [SELECT CKSW_BASE__Resource__c, CKSW_BASE__Location__c, (SELECT Name, Previous_Status__c, New_Status__c, comment__c FROM Service_Status_History__r) FROM CKSW_BASE__Service__c WHERE id=:id];         
    histories = services.Service_Status_History__r;
}
public String getService()
{
    return JSON.Serialize(services);   
}
public String getHistory()
{
    return JSON.Serialize(histories);
}

}