You need to sign in to do that
Don't have an account?
景資 片口 10
How to query custom object via javascript using AJAX within Visualforce. [Vf内でのAjax利用]
Though I expect I can get record IDs of the custom object "AddtionalLabels__c" using javascript including AJAX called by onclick event on apex:panelGrid in Visualforce page, It does not work.(at Line 14)
The Vf page is below.
Line 10 does work.
How can I fix it? Or is there fatal mistake?
(Sorry for using crappy English.)
<Japanese>
お世話になります。
VisualforcePageで、apex:panelGridのonclickイベントでjavascriptを呼び出し、
javascriptからAjaxを利用してカスタムオブジェクト"AddtionalLabels__c"をクエリ取得しようとしています。
期待では下記コード14行目"alert(sobjects[i].Id);"のところでアラートが表示されると思ったのですが、されません。
問題点と解決策をご教示くださいますでしょうか。
----------------------------------------------------------------------------------
The Vf page is below.
Line 10 does work.
How can I fix it? Or is there fatal mistake?
(Sorry for using crappy English.)
<Japanese>
お世話になります。
VisualforcePageで、apex:panelGridのonclickイベントでjavascriptを呼び出し、
javascriptからAjaxを利用してカスタムオブジェクト"AddtionalLabels__c"をクエリ取得しようとしています。
期待では下記コード14行目"alert(sobjects[i].Id);"のところでアラートが表示されると思ったのですが、されません。
問題点と解決策をご教示くださいますでしょうか。
----------------------------------------------------------------------------------
- <apex:page standardController="AddtionalLabels__c" extensions="AddLabelSettings,AdditionalLabelExtension" id="Page">
- <script src="/soap/ajax/32.0/connection.js" type="text/javascript"></script>
- <script src="/soap/ajax/32.0/apex.js" type="text/javascript"></script>
- <script type="text/javascript">
- function showMessage(){
- var aId = "{!AdlId}";
- alert(aId);
- var sobjects = sforce.connection.retrieve("Id,Name", "AddtionalLabels__c", ['a0UN0000006se4qMAA']);
- for (var i=0; i < sobjects.length; i++) {
- alert(sobjects[i].Id);
- }
- }
- </script>
- <apex:form target="_blank">
- <apex:panelGrid columns="4" columnClasses="col" styleClass="grd" onclick="showMessage();">
- <apex:outputText value="1A" styleClass="cell"/>
- <apex:outputText value="2A" styleClass="cell"/>
- <apex:outputText value="3A" styleClass="cell"/>
- <apex:outputText value="4A" styleClass="cell"/>
- </apex:panelGrid>
- </apex:form>
- </apex:page>
You need to enabled connection.js script like below
Then query using, sforce.connection.query, example below:
For details information, please visit this link (https://developer.salesforce.com/docs/atlas.en-us.ajax.meta/ajax/sforce_api_ajax_vf_sample.htm)
Hope this will provide your some insight!!!
Let me know if you need more help on this.
Thanks,
Gaurav
Skype: gaurav62990
Support: gauravgarg.nmims@gmail.com
I got it!