-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
3Questions
-
6Replies
Allowing users to Edit "Field Set" fields on a Custom VF Page
I am employing Field Sets on a custom Opportunity Page due to a need to reduce the use of Formula fields, and instead leverage the lookup capabilities of a VF page. As a bonus, I am looking to make all fields of the Field Set editable, even those of the type Account > fieldName.
My question is if it is possible to edit the related fields on the Account from my Opportunity. For instance, I would like to be able to edit Account ID > Alliance, but when I do, the value does not save. However, I am able to save Opportunity fields that are not look ups in the field set.
Is this something that will require Apex in order to achieve. I'm thinking that is probably so, but I'm not clear.
Here is the page block section I have for Accounts on the Opportunity:
Thanks in advance,
TDM
My question is if it is possible to edit the related fields on the Account from my Opportunity. For instance, I would like to be able to edit Account ID > Alliance, but when I do, the value does not save. However, I am able to save Opportunity fields that are not look ups in the field set.
Is this something that will require Apex in order to achieve. I'm thinking that is probably so, but I'm not clear.
Here is the page block section I have for Accounts on the Opportunity:
<apex:pageBlockSection title="Client Information on Account"/> <apex:pageBlockSection columns="2"> <apex:repeat value="{!$ObjectType.Opportunity.FieldSets.Related_Account_Information}" var="f"> <apex:inputField value="{!Opportunity[f]}"> </apex:inputField> </apex:repeat> </apex:pageBlockSection>
Thanks in advance,
TDM
- Tony DeMarco
- August 05, 2015
- Like
- 0
- Continue reading or reply
Multiple queries for Apex batch job -- too many queries error
So the use case is as follows: On the Account page there is the territories field that for a given account will show whatever territories are assigned to that particular Account. So, as an example, Acme Corp. may show a territories field of National, Northeast, and NY on the page. However, in reporting, SFDC returns for the Account by territories report individual line items for Acme Corporation for National, Northeast and NY respectively. The consumer requirement here is to report on territories for Accounts in the same manner they are displayed on the Account page: all concatenated within the same field.
So given there is no way to do this via formula, I investigated doing via Apex. It turned out that 4 objects would be needed to produce the territory relationship for Accounts: Account, AccountShare, Group, & Territory. However, the kicker is that basically 3 separate queries are needed to accoumplish this. The parent-child relationships are not accessble in SOQL, and of course you can't do joins between objects like you can in T-SQL unless there is that parent-child relationship.
So I attempted a batch job to somehow put this together. However, my approach is wrong in that I am running into query limits with my compiled code, and I am not sure how to structure this to get around the problem. Below is my compliled code that errors out. Guidance would be appreciated. Thanks in advance, TDM
So given there is no way to do this via formula, I investigated doing via Apex. It turned out that 4 objects would be needed to produce the territory relationship for Accounts: Account, AccountShare, Group, & Territory. However, the kicker is that basically 3 separate queries are needed to accoumplish this. The parent-child relationships are not accessble in SOQL, and of course you can't do joins between objects like you can in T-SQL unless there is that parent-child relationship.
So I attempted a batch job to somehow put this together. However, my approach is wrong in that I am running into query limits with my compiled code, and I am not sure how to structure this to get around the problem. Below is my compliled code that errors out. Guidance would be appreciated. Thanks in advance, TDM
global class batchTerritoryCustomUpdate implements Database.Batchable<sObject> { //The purpose of this batchClass is to return concatenated Territory Names to the Account object custom field Account_Territory__c for reporting purpose specific to user requests global Database.QueryLocator start(Database.BatchableContext BC) { String query = 'Select Id From Account'; return Database.getQueryLocator(query); // returns AccountId and UserOrGroupId for queries below. } global void execute(Database.BatchableContext BC, List<Account> scope) { Integer i = 0; for(Account updateAccount : scope) { String acctID = updateAccount.Id; String relId; String groupId; String matchinAcctId; List <AccountShare> aShare = new List <AccountShare>(); aShare = [Select AccountId, UserOrGroupId from AccountShare Where RowCause = 'Territory' and AccountId =: acctID]; Do{ for(AccountShare ash : aShare) // setup accounts for update { groupId = ash.UserOrGroupId; List <Group> pickGroup = new List<Group>(); pickGroup = [Select RelatedId from Group where Type ='Territory' and Id =: groupId]; For(Group selectGroup : pickGroup) //loop through Group data { relId = selectGroup.RelatedId; String terrName = '|'; List <Territory> terra = new List <Territory>(); terra = [Select Name from Territory Where Id =: relId]; for(Territory terraNova : terra) //loop through Territory data { List <Account> matchAccount = new List <Account>(); matchAccount = [Select Id from Account where Id =: acctId]; For(Account finalAcct : matchAccount) { terrName = terrName + terraNova.Name + '|'; matchinAcctId = finalAcct.Id; finalAcct.Id = acctId; updateAccount.Account_Territory__c = terrName; //write the concatenated territories to the custom Account field } } } } } while(matchinAcctId==acctId); update scope; } } global void finish(Database.BatchableContext BC) { } }
- Tony DeMarco
- June 20, 2015
- Like
- 0
- Continue reading or reply
Pass a vlalue from a trigger to a class and return a value from the class back to the trigger
Is this possible?
from the trigger:
//call out to the class
returnStateAbbreviations f = new returnStateAbbreviations();
f.returnStateAbbreviations(stateName);
//attempt to return from class
public with sharing class returnStateAbbreviations
{
public string returnState(string stateName)
{
String abbr;
String stateAbbr;
if(stateName=='Alabama')
{
stateAbbr = 'AL';
} //
// etc
abbr = stateAbbr;
return abbr;
}
}
how would I then receive abbr back at the trigger?
from the trigger:
//call out to the class
returnStateAbbreviations f = new returnStateAbbreviations();
f.returnStateAbbreviations(stateName);
//attempt to return from class
public with sharing class returnStateAbbreviations
{
public string returnState(string stateName)
{
String abbr;
String stateAbbr;
if(stateName=='Alabama')
{
stateAbbr = 'AL';
} //
// etc
abbr = stateAbbr;
return abbr;
}
}
how would I then receive abbr back at the trigger?
- Tony DeMarco
- April 27, 2015
- Like
- 0
- Continue reading or reply
Allowing users to Edit "Field Set" fields on a Custom VF Page
I am employing Field Sets on a custom Opportunity Page due to a need to reduce the use of Formula fields, and instead leverage the lookup capabilities of a VF page. As a bonus, I am looking to make all fields of the Field Set editable, even those of the type Account > fieldName.
My question is if it is possible to edit the related fields on the Account from my Opportunity. For instance, I would like to be able to edit Account ID > Alliance, but when I do, the value does not save. However, I am able to save Opportunity fields that are not look ups in the field set.
Is this something that will require Apex in order to achieve. I'm thinking that is probably so, but I'm not clear.
Here is the page block section I have for Accounts on the Opportunity:
Thanks in advance,
TDM
My question is if it is possible to edit the related fields on the Account from my Opportunity. For instance, I would like to be able to edit Account ID > Alliance, but when I do, the value does not save. However, I am able to save Opportunity fields that are not look ups in the field set.
Is this something that will require Apex in order to achieve. I'm thinking that is probably so, but I'm not clear.
Here is the page block section I have for Accounts on the Opportunity:
<apex:pageBlockSection title="Client Information on Account"/> <apex:pageBlockSection columns="2"> <apex:repeat value="{!$ObjectType.Opportunity.FieldSets.Related_Account_Information}" var="f"> <apex:inputField value="{!Opportunity[f]}"> </apex:inputField> </apex:repeat> </apex:pageBlockSection>
Thanks in advance,
TDM
- Tony DeMarco
- August 05, 2015
- Like
- 0
- Continue reading or reply
Too many sql queries while executing text class
Hello,
I have below piece of code, which worked well for 1 month and the test class was also sucessful.
Wheni check it again it gevew, Too many sql queries error for a line.
When i execute this line in Execute query then it returns only 15 rows, i have no idea why it fails
I have below piece of code, which worked well for 1 month and the test class was also sucessful.
Wheni check it again it gevew, Too many sql queries error for a line.
When i execute this line in Execute query then it returns only 15 rows, i have no idea why it fails
List temp = new List(); try{ temp = [SELECT EFX_Category__c FROM ProfileSkill where EFX_Type__c ='Certifications' ORDER BY EFX_Category__c] ; }Catch(DmlException de ){ System.debug(de); }
- Simrin
- June 23, 2015
- Like
- 0
- Continue reading or reply
Multiple queries for Apex batch job -- too many queries error
So the use case is as follows: On the Account page there is the territories field that for a given account will show whatever territories are assigned to that particular Account. So, as an example, Acme Corp. may show a territories field of National, Northeast, and NY on the page. However, in reporting, SFDC returns for the Account by territories report individual line items for Acme Corporation for National, Northeast and NY respectively. The consumer requirement here is to report on territories for Accounts in the same manner they are displayed on the Account page: all concatenated within the same field.
So given there is no way to do this via formula, I investigated doing via Apex. It turned out that 4 objects would be needed to produce the territory relationship for Accounts: Account, AccountShare, Group, & Territory. However, the kicker is that basically 3 separate queries are needed to accoumplish this. The parent-child relationships are not accessble in SOQL, and of course you can't do joins between objects like you can in T-SQL unless there is that parent-child relationship.
So I attempted a batch job to somehow put this together. However, my approach is wrong in that I am running into query limits with my compiled code, and I am not sure how to structure this to get around the problem. Below is my compliled code that errors out. Guidance would be appreciated. Thanks in advance, TDM
So given there is no way to do this via formula, I investigated doing via Apex. It turned out that 4 objects would be needed to produce the territory relationship for Accounts: Account, AccountShare, Group, & Territory. However, the kicker is that basically 3 separate queries are needed to accoumplish this. The parent-child relationships are not accessble in SOQL, and of course you can't do joins between objects like you can in T-SQL unless there is that parent-child relationship.
So I attempted a batch job to somehow put this together. However, my approach is wrong in that I am running into query limits with my compiled code, and I am not sure how to structure this to get around the problem. Below is my compliled code that errors out. Guidance would be appreciated. Thanks in advance, TDM
global class batchTerritoryCustomUpdate implements Database.Batchable<sObject> { //The purpose of this batchClass is to return concatenated Territory Names to the Account object custom field Account_Territory__c for reporting purpose specific to user requests global Database.QueryLocator start(Database.BatchableContext BC) { String query = 'Select Id From Account'; return Database.getQueryLocator(query); // returns AccountId and UserOrGroupId for queries below. } global void execute(Database.BatchableContext BC, List<Account> scope) { Integer i = 0; for(Account updateAccount : scope) { String acctID = updateAccount.Id; String relId; String groupId; String matchinAcctId; List <AccountShare> aShare = new List <AccountShare>(); aShare = [Select AccountId, UserOrGroupId from AccountShare Where RowCause = 'Territory' and AccountId =: acctID]; Do{ for(AccountShare ash : aShare) // setup accounts for update { groupId = ash.UserOrGroupId; List <Group> pickGroup = new List<Group>(); pickGroup = [Select RelatedId from Group where Type ='Territory' and Id =: groupId]; For(Group selectGroup : pickGroup) //loop through Group data { relId = selectGroup.RelatedId; String terrName = '|'; List <Territory> terra = new List <Territory>(); terra = [Select Name from Territory Where Id =: relId]; for(Territory terraNova : terra) //loop through Territory data { List <Account> matchAccount = new List <Account>(); matchAccount = [Select Id from Account where Id =: acctId]; For(Account finalAcct : matchAccount) { terrName = terrName + terraNova.Name + '|'; matchinAcctId = finalAcct.Id; finalAcct.Id = acctId; updateAccount.Account_Territory__c = terrName; //write the concatenated territories to the custom Account field } } } } } while(matchinAcctId==acctId); update scope; } } global void finish(Database.BatchableContext BC) { } }
- Tony DeMarco
- June 20, 2015
- Like
- 0
- Continue reading or reply
Pass a vlalue from a trigger to a class and return a value from the class back to the trigger
Is this possible?
from the trigger:
//call out to the class
returnStateAbbreviations f = new returnStateAbbreviations();
f.returnStateAbbreviations(stateName);
//attempt to return from class
public with sharing class returnStateAbbreviations
{
public string returnState(string stateName)
{
String abbr;
String stateAbbr;
if(stateName=='Alabama')
{
stateAbbr = 'AL';
} //
// etc
abbr = stateAbbr;
return abbr;
}
}
how would I then receive abbr back at the trigger?
from the trigger:
//call out to the class
returnStateAbbreviations f = new returnStateAbbreviations();
f.returnStateAbbreviations(stateName);
//attempt to return from class
public with sharing class returnStateAbbreviations
{
public string returnState(string stateName)
{
String abbr;
String stateAbbr;
if(stateName=='Alabama')
{
stateAbbr = 'AL';
} //
// etc
abbr = stateAbbr;
return abbr;
}
}
how would I then receive abbr back at the trigger?
- Tony DeMarco
- April 27, 2015
- Like
- 0
- Continue reading or reply