-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
5Questions
-
2Replies
<apex:inputfield> tag not working with custom modal popup
I've a custom modal in which i have a pageblock section to create a Task for the sobjects i select.
The <apex:inputfield> is not binding with the sobject Task as I'am gettiing empty task values
Need help on this. How can i fix this?
VF Code:
Apex Code:

The <apex:inputfield> is not binding with the sobject Task as I'am gettiing empty task values
Need help on this. How can i fix this?
VF Code:
<apex:form >
<div id="simpleModalTask" class="modal">
<div class="modal-content-TE">
<div class="modal-header">
<span class="closeBtn">×</span>
<h2>Create Task</h2>
</div>
<div class="modal-body">
<center style="padding-left: 40px;">
<apex:pageBlock >
<apex:pageBlockSection columns="2">
<apex:repeat value="{!TaskFields}" var="fld">
<apex:inputField value="{!massTask[fld]}"/>
</apex:repeat>
</apex:pageBlockSection>
</apex:pageBlock>
<br/><br/>
</center>
</div>
<div class="modal-footer">
<apex:commandbutton onClick="createTask()" value="Create" reRender="simpleModalTask" status="detailStatus"/>
<apex:commandbutton onClick="closepopTask()" value="Cancel" reRender="simpleModalTask"/>
<apex:actionFunction action="{!createMainTasks}" name="createTask" reRender="NoFieldPB,MainTablePB"/>
<apex:actionFunction name="cancel" reRender="NoFieldPB,MainTablePB"/>
</div>
</div>
</div>
</apex:form>
JavaScript Code:
<script>
// Get modal element
var modalTask = document.getElementById('simpleModalTask');
// Get close button
var closeBtnTask = document.getElementsByClassName('closeBtn')[1];
// Listen for close click
closeBtnTask.addEventListener('click', closeModalTask);
// Listen for outside click
window.addEventListener('click', outsideClickTask);
// Function to open modal
function openModalTask(){
modalTask.style.display = 'block';
}
// Function to close modal
function closeModalTask(){
modalTask.style.display = 'none';
}
// Function to close modal if outside click
function outsideClickTask(e){
if(e.target == modalTask){
modalTask.style.display = 'none';
}
}
function createTask(){
createTask();
modalTask.style.display = 'none';
}
function closepopTask(){
cancel();
modalTask.style.display = 'none';
}
document.onkeydown = function(evt) {
evt = evt || window.event;
var isEscape = false;
if ("key" in evt) {
isEscape = (evt.key == "Escape" || evt.key == "Esc");
} else {
isEscape = (evt.keyCode == 27);
}
if (isEscape) {
modal.style.display = 'none';
modalTask.style.display = 'none';
modalEvent.style.display = 'none';
}
};
</script>
Apex Code:
public PageReference createMainTasks(){
if(selectedObj != null){
List<Task> mainToTask = new List<Task>();
for(MainRecordWrapperClass mwc: Paging.myData){
if(mwc.isSelected){
System.debug(massTask); // This comes out to be empty
Task t = new Task();
t.Subject = massTask.subject;
t.WhoId = massTask.whoId;
t.Status = massTask.status;
t.ActivityDate = massTask.ActivityDate;
t.type = massTask.type;
t.WhatId = mwc.mainRecords.id;
mainToTask.add(t);
}
}
try{
insert mainToTask;
massTask = new Task();
instantiateMainObjLst();
}catch(Exception e){
System.debug('ERROR: ' + e.getcause() + ': ' + e.getmessage()); // Required field missing
ApexPages.addMessages(e);
}
}
return null;
}
-
- Chirag_Joshi
- October 08, 2018
- Like
- 0
How to get access to google basic profile information with access_token
I have a force.com site where I am using google authentication
The authentication is working fine. I am getting the acess_tokne in json
After this i want to get the basic profile information about the user from google like his name, email, etc
How to use access_token to get this and what url to send request at
Here is what i am using in force.com site
Site URL:
http://bodaciousithub01-developer-edition.ap5.force.com/GoogleAuth
VF Page:
Apex Controller:
The authentication is working fine. I am getting the acess_tokne in json
After this i want to get the basic profile information about the user from google like his name, email, etc
How to use access_token to get this and what url to send request at
Here is what i am using in force.com site
Site URL:
http://bodaciousithub01-developer-edition.ap5.force.com/GoogleAuth
VF Page:
<apex:page controller="GoogleAuthController" showheader="false" sidebar="false">
<apex:form >
<apex:pageblock title="Google Authentication">
<apex:commandButton value="Connect To Google" action="{!connect}"/>
<apex:commandButton value="Fetch Auth Token" action="{!showtoken}"/>
<br/><br/>
{!bodyprint}
</apex:pageblock>
</apex:form>
</apex:page>
Apex Controller:
public class GoogleAuthController {
public string authtoken{get;set;}
public string refereshtoken{get;set;}
public string bodyprint{get;set;}
//Settings needed on the google cloud console.One can store this securely in custom settings or an object.
public static final string CLIENT_SECRET='ZpH3EjBufPYchj1t97yerzaA'; //Fill as per your registered app settings in google console
public static final string CLIENT_ID='472650385442-r0gt7rpvg4f54ao65hiq5m2so4afrs3p.apps.googleusercontent.com'; //Fill as per your registered app settings in google console
public static final string REDIRECT_URL='https://bodaciousithub01-developer-edition.ap5.force.com/GoogleAuth';
public static final string OAUTH_TOKEN_URL='https://accounts.google.com/o/oauth2/token';
public static final string OAUTH_CODE_END_POINT_URL='https://accounts.google.com/o/oauth2/auth';
public static final string GRANT_TYPE='grant_type=authorization_code';
//Scope URL as per oauth 2.0 guide of the google
public static final string SCOPE='https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile';
public static final string STATE='/profile';
//Approval Prompt Constant
public static final string APPROVAL_PROMPT='force';
public pagereference connect(){
String x=OAUTH_CODE_END_POINT_URL+'?scope='+EncodingUtil.urlEncode(SCOPE,'UTF-8')+'&state='+EncodingUtil.urlEncode(STATE,'UTF-8')+'&redirect_uri='+EncodingUtil.urlEncode(REDIRECT_URL,'UTF-8')+'&response_type=code&client_id='+CLIENT_ID+'&approval_prompt='+APPROVAL_PROMPT;
System.debug(x);
pagereference p=new pagereference(x);
return p;
}
public pagereference showtoken(){
String codeparam=apexpages.currentpage().getparameters().get('code');
System.debug('codeparam: ' + codeparam);
// Instantiate a new http object
Http h = new Http();
String body='code='+codeparam+'&client_id='+CLIENT_ID+'&client_secret='+CLIENT_SECRET+'&redirect_uri='+REDIRECT_URL+'&'+GRANT_TYPE;
// Instantiate a new HTTP request, specify the method (GET) as well as the endpoint
HttpRequest req = new HttpRequest();
req.setEndpoint(OAUTH_TOKEN_URL);
req.setHeader('Content-Type','application/x-www-form-urlencoded');
req.setMethod('POST');
req.setBody(body);
system.debug('REQUEST BODY'+body);
// Send the request, and return a response
HttpResponse res = h.send(req);
System.debug('body'+res.getbody());
bodyprint=res.getbody();
return null;
}
}
-
- Chirag_Joshi
- October 03, 2018
- Like
- 0
<apex:actionsupport> not working for <apex:inputcheckbox> for "onchange" event under <apex:repeat> tag
I am trying to dynamically display objects and there related objects records in a table. I am struck with the following problem
The <apex:actionsupport> is not working for the following:
VF Page:
Apex Controller:
However the following similar sample is working fine
VF Page:
Apex Controller:
The <apex:actionsupport> is not working for the following:
VF Page:
<apex:page controller="MyController" tabStyle="Account">
<apex:form >
<apex:pageBlock title="{!selectedObj} Records">
<apex:pageBlockTable value="{!mainObjLst}" var="rec">
<apex:column headerValue="Related Records" width="10%">
<apex:commandButton value="Show" action="{!show}" reRender="relatedRec">
<apex:param name="Abc" value="{!rec.Id}" assignTo="{!recordId}"/>
</apex:commandButton>
<apex:commandButton value="Hide" action="{!hide}" reRender="relatedRec"/>
</apex:column>
<apex:repeat value="{!mainselectedFld}" var="fld">
<apex:column value="{!rec[fld]}"/>
</apex:repeat>
<apex:column id="relatedRec" breakBefore="true" colspan="{!mainselectedFld.size + 1}" >
<apex:pageBlock title="Child Records" rendered="{!showRelated}">
<apex:repeat value="{!relatedFldMapVF}" var="rlRec">
<apex:variable value="{!relatedObjLst[rlRec]}" var="myMap"/>
<apex:pageBlockSection title="{!rlRec}" columns="1">
<apex:pageBlockTable value="{!relatedObjLst[rlRec]}" var="rlLst" rendered="{!myMap.size > 0}">
<apex:column >
<apex:facet name="header">
Select
</apex:facet>
<apex:inputCheckbox>
<apex:actionSupport action="{!anyMethod}" event="onchange" />
</apex:inputCheckbox>
</apex:column>
<apex:repeat value="{!relatedFldMapVF[rlRec]}" var="fld">
<apex:column >
<apex:facet name="header">
{!$ObjectType[rlRec].Fields[fld].Label}
</apex:facet>
<apex:outputField value="{!rlLst[fld]}"/>
</apex:column>
</apex:repeat>
</apex:pageBlockTable>
</apex:pageBlockSection>
<center>
<apex:commandButton value="Delete" action="{!deleteRecords}" rendered="{!myMap.size > 0}"/>
<apex:commandButton value="Update" action="{!updateRecords}" rendered="{!myMap.size > 0}"/>
</center>
</apex:repeat>
</apex:pageBlock>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex Controller:
public class MyController{
public String selectedObj {get;set;}
public List<sObject> mainObjLst{get;set;}
public Map<String, List<sObject>> relatedObjLst{get;set;}
public Map<String, List<String>> relatedFldMap{get;set;}
public Map<String, List<String>> relatedFldMapVF {get; set;}
public Map<String, String> rlFld{get;set;}
public List<String> mainselectedFld{get;set;}
public Map<String, sObject> relatedObjectLst {get; set;}
public Id recordId{get;set;}
public Boolean showRelated{get;set;}
public Map<ID, RecordWrapperClass> mapHoldingSelectedRecords {get;set;}
public List<RecordWrapperClass> RecordWrapperRecordList {get;set;}
public MyController(){
selectedObj = 'Account';
showRelated = false;
mainselectedFld = getDefaultFields(selectedObj);
instantiaterlFld();
instantiaterelatedObjectLst();
instantiaterelatedFldMapVF();
instantiaterelatedFldMap();
mainObjLst = Database.query(getQuery());
relatedObjLst = new Map<String, List<sObject>>();
mapHoldingSelectedRecords = new Map<ID, RecordWrapperClass>();
RecordWrapperRecordList = new List<RecordWrapperClass>();
}
public void instantiaterelatedObjectLst(){
relatedObjectLst = new Map<String, sObject>();
for(String s: getAllRelatedObject(selectedObj)){
relatedObjectLst.put(s, ConvertTosObject(s));
}
}
public void instantiaterelatedFldMapVF(){
relatedFldMapVF = new Map<String, List<String>>();
for(String so: getAllRelatedObject(selectedObj)){
relatedFldMapVF.put(so, getDefaultFields(so));
}
}
public void instantiaterelatedFldMap(){
relatedFldMap = new Map<String, List<String>>();
for(String so: getAllRelatedObjectWithRelationshipName(selectedObj)){
relatedFldMap.put(so, getDefaultFields(rlFld.get(so)));
}
}
public void instantiaterlFld(){
rlFld = new Map<String, String>();
for (Schema.ChildRelationship cr: Schema.getGlobalDescribe().get(selectedObj).getDescribe().getChildRelationships())
{
rlFld.put(cr.getRelationshipName(), String.valueOf(cr.getChildSObject()));
}
}
public List<String> getAllRelatedObject(String obj){
Set<String> rObjLst = new Set<String>();
for (Schema.ChildRelationship cr: Schema.getGlobalDescribe().get(obj).getDescribe().getChildRelationships())
{
if(cr.getRelationshipName() != null)
rObjLst.add(String.valueOf(cr.getChildSObject()));
}
return filterObjectList(new List<String>(rObjLst));
}
public List<String> getAllRelatedObjectWithRelationshipName(String obj){
Set<String> rObjLst = new Set<String>();
for (Schema.ChildRelationship cr: Schema.getGlobalDescribe().get(obj).getDescribe().getChildRelationships())
{
if(getAllRelatedObject(obj).contains(String.valueOf(cr.getChildSObject())) && cr.getRelationshipName() != null)
rObjLst.add(cr.getRelationshipName());
}
return new List<String>(rObjLst);
}
public sObject ConvertTosObject(String objName){
return Schema.getGlobalDescribe().get(objName).newsObject();
}
public List<String> filterObjectList(List<String> objLst){
List<String> mainLst = new List<String>{'Account', 'Asset', 'Campaign', 'Case', 'Contact',
'Contract', 'Opportunity', 'Order',
'Product', 'Solution', 'User', 'Task', 'Event'};
Set<String> setObjLst = new Set<String>(objLst);
setObjLst.retainAll(mainLst);
return new List<String>(setObjLst);
}
public List<String> getAllFields(String obj){
return new List<String>(Schema.getGlobalDescribe().get(obj).getDescribe().fields.getmap().keyset());
}
public List<String> getRequiredFields(String obj){
List<String> reqfields = new List<String>();
for(String fld: Schema.getGlobalDescribe().get(obj).getDescribe().fields.getmap().keyset()){
if(isRequired(obj, fld)){
reqfields.add(fld);
}
}
return reqfields;
}
public List<String> getDefaultFields(String obj){
if(obj == 'Account'){
return new List<String>{'Name', 'AccountNumber', 'Phone', 'Rating', 'Type', 'Industry'};
}else if(obj == 'Asset'){
return new List<String>{'Name', 'Product2Id', 'Price', 'Quantity', 'AccountId', 'ContactId'};
}else if(obj == 'Campaign'){
return new List<String>{'Name', 'isActive', 'Type', 'Status', 'StartDate', 'EndDate'};
}else if(obj == 'Case'){
return new List<String>{'CaseNumber', 'OwnerId', 'AccountId', 'ContactId', 'Status', 'Priority', 'Origin'};
}else if(obj == 'Contact'){
return new List<String>{'FirstName', 'LastName', 'AccountId', 'Phone', 'Email'};
}else if(obj == 'Contract'){
return new List<String>{'AccountId', 'Status', 'StartDate', 'ContractTerm'};
}else if(obj == 'Lead'){
return new List<String>{'FirstName', 'LastName', 'Company', 'LeadSource'};
}else if(obj == 'Opportunity'){
return new List<String>{'Name', 'Amount', 'Probability', 'StageName', 'CloseDate', 'ForecastCategoryName'};
}else if(obj == 'Order'){
return new List<String>{'AccountId', 'ContractId', 'Status', 'EffectiveDate', 'Type'};
}else if(obj == 'Product'){
return new List<String>{'Name', 'isActive', 'Family'};
}else if(obj == 'Solution'){
return new List<String>{'SolutionName', 'isPublished', 'SolutionNumber', 'Status'};
}else if(obj == 'User'){
return new List<String>{'FirstName', 'LastName', 'Alias', 'Email', 'UserName', 'CommunityNickname'};
}else if(obj == 'Task'){
return new List<String>{'Subject', 'WhoId', 'WhatId', 'Status', 'ActivityDate', 'Type'};
}else if(obj == 'Event'){
return new List<String>{'Subject', 'StartDateTime', 'EndDateTime', 'ActivityDate'};
}
else{
return new List<String>{'Name'};
}
}
public Boolean isRequired(String obj, String fld){
return !Schema.getGlobalDescribe().get(obj).getDescribe().fields.getMap().get(fld).getDescribe().isNillable();
}
public String getQuery(){
String s = 'SELECT ' + String.join(getDefaultFields(selectedObj), ', ') + getRelatedQuery() + ' FROM ' + selectedObj;
System.debug('QUERY: ' + s);
return s;
}
public String getRelatedQuery(){
if (relatedFldMap == null || relatedFldMap.isEmpty()) return '';
String qr = ', ';
for(String s: relatedFldMap.keySet()){
qr += '( SELECT ';
if(relatedFldMap.get(s) != null && !relatedFldMap.get(s).isEmpty()){
qr += String.join(relatedFldMap.get(s), ', ');
}else{
qr += 'Name ';
}
qr += ' FROM ';
qr += s;
qr += ' ), ';
}
qr = qr.removeEnd(', ');
return qr;
}
public void show(){
showRelated = true;
sObject s = searchRecord(recordId);
for(String rName: relatedFldMap.keySet()){
relatedObjLst.put(rlFld.get(rName), (s.getsObjects(rName)!=null)? s.getsObjects(rName): new List<sObject>());
}
}
public sObject searchRecord(Id rid){
for(sObject s: mainObjLst){
if(s.id == rid){
return s;
}
}
return null;
}
public void hide(){
showRelated = false;
}
public PageReference deleteRecords(){
return null;
}
public PageReference updateRecords(){
return null;
}
public void anyMethod()
{
System.debug('Function: anyMethod');
}
public class RecordWrapperClass
{
public Boolean isSelected {get;set;}
public ID anyId {get;set;}
public RecordWrapperClass(Id anyId, Boolean isSelected) {
this.anyId = anyId;
this.isSelected = isSelected;
}
}
}
However the following similar sample is working fine
VF Page:
<apex:page controller="MyController1" tabStyle="Account">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection columns="1">
<apex:pageBlockTable value="{!acc}" var="a">
<apex:column value="{!a.Name}"/>
<apex:column breakBefore="true" colspan="1">
<apex:pageBlock >
<apex:pageBlockSection columns="1">
<apex:pageBlockTable value="{!con}" var="c">
<apex:column width="5%">
<apex:facet name="header">
First Name
</apex:facet>
<apex:inputCheckbox >
<apex:actionSupport action="{!method}" event="onchange"/>
</apex:inputCheckbox>
</apex:column>
<apex:column value="{!c.FirstName}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex Controller:
public class MyController1 {
public List<Account> acc {get;set;}
public List<Contact> con {get;set;}
public MyController1 (){
acc = [select name from account];
con = [Select firstname from contact];
}
public void method(){
System.debug('Method Called');
}
}
-
- Chirag_Joshi
- September 27, 2018
- Like
- 0
Site.com Google Authentication
I am trying to provide the site user Google authentication, so that they can login to the site by there google credentials
The single sign on is working fine when i displayed it on the visualforce page
But when i am displaying the same page as a part of site.com site The page gives me error by clicking on Login
Also since site is public and anybody can access the sites and all i want to do si to register a user through their google account, do I need any user license for this
This is the VF Page and Controller. Please have a look. Thanks
VF Page:
Apex Controller:
Error:
The single sign on is working fine when i displayed it on the visualforce page
But when i am displaying the same page as a part of site.com site The page gives me error by clicking on Login
Also since site is public and anybody can access the sites and all i want to do si to register a user through their google account, do I need any user license for this
This is the VF Page and Controller. Please have a look. Thanks
VF Page:
<apex:page controller="MyController" showHeader="false" sidebar="false">
<apex:form >
<apex:pageBlock title="Login Here">
<apex:commandButton value="Login" action="{!login}"/>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex Controller:
public class MyController {
public PageReference login(){
return new PageReference('/services/auth/sso/Google_SSO');
}
}
Error:
-
- Chirag_Joshi
- September 25, 2018
- Like
- 0
Cannot retrieve value of map from List of Map in <apex:pageblocktable> columns except 'Name'
VF Page:
Apex Controller:
Error:
<apex:page controller="FLSController2">
<apex:form >
<apex:pageBlock title="FLS Test" >
<apex:inlineEditSupport event="onDblClick"/>
<apex:pageMessages />
<apex:pageBlockTable value="{!acc}" var="a">
<apex:column headerValue="Account Name" value="{!a['Name']}" rendered="{!$ObjectType.Account.Fields.Name.Accessible}"/>
<apex:column headerValue="Phone" value="{!a['Phone']}" rendered="{!$ObjectType.Account.Fields.Phone.Accessible}"/>
<apex:column headerValue="Industry" value="{!a['Industry']}" rendered="{!$ObjectType.Account.Fields.Industry.Accessible}"/>
<apex:column headerValue="Rating" value="{!a['Rating']}" rendered="{!$ObjectType.Account.Fields.Rating.Accessible}"/>
<apex:column headerValue="Type" value="{!a['Type']}" rendered="{!$ObjectType.Account.Fields.Type.Accessible}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex Controller:
public with sharing class FLSController2 {
public List<Map<String, String>> acc;
public FLSController2(){
acc = new List<Map<String, String>>();
}
public List<Map<String, String>> getacc(){
List<Account> aList = [SELECT Name, Industry, Phone, Rating, Type FROM Account];
for(Account a: aList){
Map<String, String> m = new Map<String, String>();
m.put('Name', a.Name);
m.put('Industry', a.Industry);
m.put('Phone', a.Phone);
m.put('Rating', a.Rating);
m.put('Type', a.Type);
acc.add(m);
}
return acc;
}
}
Error:
-
- Chirag_Joshi
- September 19, 2018
- Like
- 0
How to get access to google basic profile information with access_token
I have a force.com site where I am using google authentication
The authentication is working fine. I am getting the acess_tokne in json
After this i want to get the basic profile information about the user from google like his name, email, etc
How to use access_token to get this and what url to send request at
Here is what i am using in force.com site
Site URL:
http://bodaciousithub01-developer-edition.ap5.force.com/GoogleAuth
VF Page:
Apex Controller:
The authentication is working fine. I am getting the acess_tokne in json
After this i want to get the basic profile information about the user from google like his name, email, etc
How to use access_token to get this and what url to send request at
Here is what i am using in force.com site
Site URL:
http://bodaciousithub01-developer-edition.ap5.force.com/GoogleAuth
VF Page:
<apex:page controller="GoogleAuthController" showheader="false" sidebar="false">
<apex:form >
<apex:pageblock title="Google Authentication">
<apex:commandButton value="Connect To Google" action="{!connect}"/>
<apex:commandButton value="Fetch Auth Token" action="{!showtoken}"/>
<br/><br/>
{!bodyprint}
</apex:pageblock>
</apex:form>
</apex:page>
Apex Controller:
public class GoogleAuthController {
public string authtoken{get;set;}
public string refereshtoken{get;set;}
public string bodyprint{get;set;}
//Settings needed on the google cloud console.One can store this securely in custom settings or an object.
public static final string CLIENT_SECRET='ZpH3EjBufPYchj1t97yerzaA'; //Fill as per your registered app settings in google console
public static final string CLIENT_ID='472650385442-r0gt7rpvg4f54ao65hiq5m2so4afrs3p.apps.googleusercontent.com'; //Fill as per your registered app settings in google console
public static final string REDIRECT_URL='https://bodaciousithub01-developer-edition.ap5.force.com/GoogleAuth';
public static final string OAUTH_TOKEN_URL='https://accounts.google.com/o/oauth2/token';
public static final string OAUTH_CODE_END_POINT_URL='https://accounts.google.com/o/oauth2/auth';
public static final string GRANT_TYPE='grant_type=authorization_code';
//Scope URL as per oauth 2.0 guide of the google
public static final string SCOPE='https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile';
public static final string STATE='/profile';
//Approval Prompt Constant
public static final string APPROVAL_PROMPT='force';
public pagereference connect(){
String x=OAUTH_CODE_END_POINT_URL+'?scope='+EncodingUtil.urlEncode(SCOPE,'UTF-8')+'&state='+EncodingUtil.urlEncode(STATE,'UTF-8')+'&redirect_uri='+EncodingUtil.urlEncode(REDIRECT_URL,'UTF-8')+'&response_type=code&client_id='+CLIENT_ID+'&approval_prompt='+APPROVAL_PROMPT;
System.debug(x);
pagereference p=new pagereference(x);
return p;
}
public pagereference showtoken(){
String codeparam=apexpages.currentpage().getparameters().get('code');
System.debug('codeparam: ' + codeparam);
// Instantiate a new http object
Http h = new Http();
String body='code='+codeparam+'&client_id='+CLIENT_ID+'&client_secret='+CLIENT_SECRET+'&redirect_uri='+REDIRECT_URL+'&'+GRANT_TYPE;
// Instantiate a new HTTP request, specify the method (GET) as well as the endpoint
HttpRequest req = new HttpRequest();
req.setEndpoint(OAUTH_TOKEN_URL);
req.setHeader('Content-Type','application/x-www-form-urlencoded');
req.setMethod('POST');
req.setBody(body);
system.debug('REQUEST BODY'+body);
// Send the request, and return a response
HttpResponse res = h.send(req);
System.debug('body'+res.getbody());
bodyprint=res.getbody();
return null;
}
}

- Chirag_Joshi
- October 03, 2018
- Like
- 0
Cannot retrieve value of map from List of Map in <apex:pageblocktable> columns except 'Name'
VF Page:
Apex Controller:
Error:
<apex:page controller="FLSController2">
<apex:form >
<apex:pageBlock title="FLS Test" >
<apex:inlineEditSupport event="onDblClick"/>
<apex:pageMessages />
<apex:pageBlockTable value="{!acc}" var="a">
<apex:column headerValue="Account Name" value="{!a['Name']}" rendered="{!$ObjectType.Account.Fields.Name.Accessible}"/>
<apex:column headerValue="Phone" value="{!a['Phone']}" rendered="{!$ObjectType.Account.Fields.Phone.Accessible}"/>
<apex:column headerValue="Industry" value="{!a['Industry']}" rendered="{!$ObjectType.Account.Fields.Industry.Accessible}"/>
<apex:column headerValue="Rating" value="{!a['Rating']}" rendered="{!$ObjectType.Account.Fields.Rating.Accessible}"/>
<apex:column headerValue="Type" value="{!a['Type']}" rendered="{!$ObjectType.Account.Fields.Type.Accessible}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex Controller:
public with sharing class FLSController2 {
public List<Map<String, String>> acc;
public FLSController2(){
acc = new List<Map<String, String>>();
}
public List<Map<String, String>> getacc(){
List<Account> aList = [SELECT Name, Industry, Phone, Rating, Type FROM Account];
for(Account a: aList){
Map<String, String> m = new Map<String, String>();
m.put('Name', a.Name);
m.put('Industry', a.Industry);
m.put('Phone', a.Phone);
m.put('Rating', a.Rating);
m.put('Type', a.Type);
acc.add(m);
}
return acc;
}
}
Error:

- Chirag_Joshi
- September 19, 2018
- Like
- 0