• john4sfdc
  • NEWBIE
  • 50 Points
  • Member since 2013

  • Chatter
    Feed
  • 2
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 16
    Replies
Hello

Newbie here. I fear this is a bit basic, but I've been looking for answers for a couple of weeks with no luck. Hopefully this isn't too much to ask of the community.

​I have a custom object and a Visualforce page to edit the records. There is a Due Date field on the object of type Date.  When the record is edited, we need the date that is displayed in the input field to appear either in US format, or according to the user's locale.  We are fine with either. What we always get is yyyy-mm-dd. We want mm/dd/yyyy. Have read that Visualforce is supposed to respect a user's locale settings.

There are lots of posts around date formatting when you are using apex:outputText and apex:param tags when you are just viewing the data, but that doesn't work when you have an apex:inputField tag.

Here is the code:

<apex:page standardController="MyObject__c" docType="html-5.0" >
 <apex:form>
  <apex:outputPanel layout="block" >
   <apex:outputLabel value="Due Date" for="duedate"/>
   <apex:inputField type="date" showDatePicker="false" styleClass="slds-input" id="duedate" value="{!MyObject__c.Due_Date__c}"/>
  </apex:outputPanel>
 </apex:form>
</apex:page>

​​I have found a few approaches that deal with some custom controller code. But it doesn't seem like it should be that difficult or that much work. Is there some easy formatting option that I am missing? The code above is easy with the simple binding right to the object field. I did some experimenting trying to override the field in a controller extension to format a string using a getter. But I couldn't get that exactly right from the perspective of how to reference the controller extension's methods in the page, let alone what to do during a save operation. But if doing it in controller code is necessary, I'd appreciate some pointers in the right direction. I'm going through Trailhead and some other educational materials as I can, but in parallel have some development requests to address.

Thanks!
Steve​


I am trying to use for update in the SOQL query for territory object. I recieve the below error

"SObject type does not allow locking rows"

Where as i tried to use the for update keyword on account and contacts and it did work. is there any limitation to use the FOR UPDATE on territories.
10:29:01.602 (147602972910)|SYSTEM_METHOD_EXIT|[218]|LIST<Account_Territory__c>.add(Object)
10:29:01.602 (147602978431)|SYSTEM_METHOD_ENTRY|[216]|system.ListIterator.hasNext()
10:29:01.602 (147602986344)|SYSTEM_METHOD_EXIT|[216]|system.ListIterator.hasNext()
10:29:01.603 (147603015860)|SYSTEM_CONSTRUCTOR_ENTRY|[224]|<init>()
10:29:01.603 (147603044944)|SYSTEM_CONSTRUCTOR_EXIT|[224]|<init>()
10:29:01.603 (147603054198)|SYSTEM_METHOD_ENTRY|[225]|LIST<Account_Territory__c>.isEmpty()
10:29:01.603 (147603069413)|SYSTEM_METHOD_EXIT|[225]|LIST<Account_Territory__c>.isEmpty()
10:29:01.603 (147603376705)|SYSTEM_METHOD_ENTRY|[226]|Database.delete(LIST<SObject>, Boolean)
10:29:01.603 (147603403830)|DML_BEGIN|[226]|Op:Delete|Type:Account_Territory__c|Rows:2000
10:46:41.895 (1207895617727)|DML_END|[226]

The log ends here and shows Internal Salesforce error.. is there any wrong with line 226??

User-added image
20.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
12:01:10.119 (119157280)|EXECUTION_STARTED
12:01:10.119 (119200824)|CODE_UNIT_STARTED|[EXTERNAL]|01pE000000000a1|TerritoryAlignment
12:01:10.161 (161388605)|METHOD_ENTRY|[5]|01pE000000000a1|TerritoryAlignment.TerritoryAlignment()
12:01:10.161 (161466583)|METHOD_EXIT|[5]|TerritoryAlignment
12:01:10.182 (182010006)|METHOD_ENTRY|[8]|01pA0000001oPla|BatchJobUtils.BatchJobUtils()
12:01:10.182 (182084454)|SYSTEM_CONSTRUCTOR_ENTRY|[30]|<init>(Integer)
12:01:10.182 (182137857)|SYSTEM_CONSTRUCTOR_EXIT|[30]|<init>(Integer)
12:01:10.182 (182176141)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182194798)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182208546)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182219542)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182231733)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182242334)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182254105)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182264782)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182276570)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182287244)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182299032)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182309704)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182321427)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182336971)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182349212)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182359748)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182371449)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182382116)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182393862)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182404537)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182429131)|METHOD_EXIT|[8]|BatchJobUtils
12:01:10.183 (183647973)|METHOD_ENTRY|[81]|01pA0000001oPla|BatchJobUtils.setRunning(Id)
12:01:10.185 (185580043)|SOQL_EXECUTE_BEGIN|[120]|Aggregations:0|select Id from Batch_Job__c where Id = :tmpVar1
12:01:10.188 (188411566)|SOQL_EXECUTE_END|[120]|Rows:1
12:01:10.188 (188550692)|SYSTEM_METHOD_ENTRY|[121]|LIST<Batch_Job__c>.isEmpty()
12:01:10.188 (188577929)|SYSTEM_METHOD_EXIT|[121]|LIST<Batch_Job__c>.isEmpty()
12:01:10.188 (188598904)|SYSTEM_METHOD_ENTRY|[122]|LIST<Batch_Job__c>.get(Integer)
12:01:10.188 (188646639)|SYSTEM_METHOD_EXIT|[122]|LIST<Batch_Job__c>.get(Integer)
12:01:10.188 (188740846)|DML_BEGIN|[124]|Op:Update|Type:Batch_Job__c|Rows:1
12:01:10.261 (261542811)|DML_END|[124]
12:01:10.261 (261592724)|METHOD_EXIT|[81]|01pA0000001oPla|BatchJobUtils.setRunning(Id)
12:01:10.261 (261659324)|SYSTEM_METHOD_ENTRY|[83]|System.debug(ANY)
12:01:10.261 (261692205)|USER_DEBUG|[83]|DEBUG|Query : SELECT Id, Customer__c, Territory_Custom__c,  Territory_Custom__r.Name, Territory_Custom__r.Territory_Id__c,  Territory_Custom__r.Group_Id__c,  Account_Share_Id__c, Is_Marked_for_Delete__c  FROM Account_Territory__c  WHERE Account_Share_Id__c = NULL and Is_Marked_for_Delete__c = FALSE  LIMIT 1000000
12:01:10.261 (261701167)|SYSTEM_METHOD_EXIT|[83]|System.debug(ANY)
12:01:10.272 (272605280)|METHOD_ENTRY|[12]|01pA0000001oPmU|CodeSettingUtils.CodeSettingUtils()
12:01:10.272 (272702512)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272753205)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272778685)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272794337)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272812314)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272826579)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272844713)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272858708)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272876043)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272889717)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272905891)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272919455)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272938113)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272951908)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272969423)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272983080)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273000441)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273015886)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273032566)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273046930)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273061714)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273075370)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273091822)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273105418)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273121497)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273135824)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273153465)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273167335)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273184698)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273198534)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273215033)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273229240)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273246458)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273260371)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273277037)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273290708)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273313062)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273327845)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273345652)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273359332)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273376709)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273390353)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273410616)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273425681)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273443366)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273457066)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273474137)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273487842)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273510383)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273526564)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273544474)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273558346)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273575787)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273589674)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273620909)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273635533)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273652403)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273666294)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273683891)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273697875)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273713313)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273726754)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273743582)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273757228)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273773558)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273787398)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273805115)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273818970)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273835793)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273849572)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273866608)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273880469)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273895803)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273909396)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273929531)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273943837)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273970773)|METHOD_EXIT|[12]|CodeSettingUtils
12:01:10.275 (275575812)|METHOD_ENTRY|[85]|01pA0000001oPmU|CodeSettingUtils.getTargetID(String)
12:01:10.275 (275808916)|SYSTEM_METHOD_ENTRY|[223]|CommonSettings__c.getInstance(String)
12:01:10.277 (277516687)|SYSTEM_METHOD_EXIT|[223]|CommonSettings__c.getInstance(String)
12:01:10.277 (277580360)|SYSTEM_CONSTRUCTOR_ENTRY|[224]|<init>()
12:01:10.277 (277612047)|SYSTEM_CONSTRUCTOR_EXIT|[224]|<init>()
12:01:10.277 (277621769)|SYSTEM_CONSTRUCTOR_ENTRY|[225]|<init>()
12:01:10.277 (277634537)|SYSTEM_CONSTRUCTOR_EXIT|[225]|<init>()
12:01:10.277 (277672936)|SYSTEM_METHOD_ENTRY|[227]|String.split(String)
12:01:10.277 (277717624)|SYSTEM_METHOD_EXIT|[227]|String.split(String)
12:01:10.280 (280341599)|SOQL_EXECUTE_BEGIN|[229]|Aggregations:0|select Id from User where username IN :tmpVar1
12:01:10.285 (285461038)|SOQL_EXECUTE_END|[229]|Rows:0
12:01:10.285 (285638711)|SYSTEM_METHOD_ENTRY|[230]|LIST<User>.size()
12:01:10.285 (285667057)|SYSTEM_METHOD_EXIT|[230]|LIST<User>.size()
12:01:10.285 (285686223)|METHOD_EXIT|[85]|01pA0000001oPmU|CodeSettingUtils.getTargetID(String)
12:01:10.285 (285726722)|SYSTEM_METHOD_ENTRY|[85]|com.salesforce.api.interop.apex.bcl.DatetimeMethods.now()
12:01:10.285 (285749377)|SYSTEM_METHOD_EXIT|[85]|com.salesforce.api.interop.apex.bcl.DatetimeMethods.now()
12:01:10.285 (285773459)|SYSTEM_METHOD_ENTRY|[85]|String.valueOf(Object)
12:01:10.285 (285795208)|SYSTEM_METHOD_EXIT|[85]|String.valueOf(Object)
12:01:10.294 (294655813)|METHOD_ENTRY|[14]|01pA0000001oPmk|EmailUtils.EmailUtils()
12:01:10.294 (294682503)|METHOD_EXIT|[14]|EmailUtils
12:01:10.296 (296055727)|METHOD_ENTRY|[85]|01pA0000001oPmk|EmailUtils.sendEmail(LIST<String>, String, String, Boolean, LIST<Messaging.EmailFileAttachment>, Boolean)
12:01:10.296 (296089329)|SYSTEM_METHOD_ENTRY|[48]|LIST<String>.size()
12:01:10.296 (296134515)|SYSTEM_METHOD_EXIT|[48]|LIST<String>.size()
12:01:10.296 (296149751)|METHOD_EXIT|[85]|01pA0000001oPmk|EmailUtils.sendEmail(LIST<String>, String, String, Boolean, LIST<Messaging.EmailFileAttachment>, Boolean)
12:01:10.296 (296177294)|SYSTEM_METHOD_ENTRY|[90]|Database.getQueryLocator(String)
12:01:10.302 (302054710)|SOQL_EXECUTE_BEGIN|[90]|Aggregations:0|SELECT Id, Customer__c, Territory_Custom__c,  Territory_Custom__r.Name, Territory_Custom__r.Territory_Id__c,  Territory_Custom__r.Group_Id__c,  Account_Share_Id__c, Is_Marked_for_Delete__c  FROM Account_Territory__c 
12:31:17.661 (1807661545838)|EXCEPTION_THROWN|[90]|System.UnexpectedException: Internal Salesforce.com Query Error
12:31:17.661 (1807661671103)|SYSTEM_METHOD_EXIT|[90]|Database.getQueryLocator(String)
12:31:17.661 (1807661743998)|FATAL_ERROR|System.UnexpectedException: Internal Salesforce.com Query Error

Class.TerritoryAlignment.start: line 90, column 1
12:31:17.952 (1807661876825)|CUMULATIVE_LIMIT_USAGE
12:31:17.952|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 0 out of 200
  Number of query rows: 0 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 0 out of 150
  Number of DML rows: 0 out of 10000
  Maximum CPU time: 0 out of 60000
  Maximum heap size: 0 out of 12000000
  Number of callouts: 0 out of 0
  Number of Email Invocations: 0 out of 10
  Number of future calls: 0 out of 0
  Number of Mobile Apex push calls: 0 out of 10

12:31:17.952|CUMULATIVE_LIMIT_USAGE_END

12:31:17.661 (1807661912023)|CODE_UNIT_FINISHED|TerritoryAlignment

I need to refer a custom settting field in the Javascript button.

How do we refer custo setting values in Java script button code

I need to refer a custom settting field in the Javascript button.

How do we refer custo setting values in Java script button code

Datetime insdate;
insdate = 2013-10-07 00:00:00;
System.debug(insdate);

 

when i try to execute this as  annonymous, I get the error unexpected token: '2013-10-07'

 

My question is, How do we assign a datetime value to a variable?

Can anybody help me in executing the below batch class using annonomous apex

 

global class batchUpdateAccounts implements Database.Batchable<sObject>,Database.Stateful{

global Database.QueryLocator start(Database.BatchableContext bc){

    return database.getQuerylocator('select id,Category__c,Family__c from Account');
}

global void execute(Database.BatchableContext bc, List<SObject> scope) {
    
        List<Account> accs = (List<Account>)scope;
        List<Account> accsToUpdate = new List<Account>();
        List<Global_families__c> gfslst = new List<Global_families__c>();
        gfslst = [select Is_Global__c, Name from Global_families__c];
 
        for(Account acunts : accs){
        for(Global_families__c lstglobal: gfslst ){
        if(acunts.Family__c == lstglobal.Name && lstglobal.Is_Global__c == TRUE){
        Acunts.Family__c = 'Global';
        accsToUpdate.add(acunts);
        }
        }
        }
        
        update accsToUpdate;
        
       
}

global void finish(Database.BatchableContext bc){
        

}

}

I am having a view state error on my vf page.

Below the controller code which i believe is causing the eror. Can anyone help me which part of the code is causing this error

 

public class Team_Attach_ACL
{
    id accountid,rectypeid;
    public AccountProgramAttachment__c naObj{set; get;}
   public Attachment attachment1{set; get;}
    public string filename { get;set;}
    public Team_Attach_ACL(ApexPages.StandardController controller)
    {
        accountid=system.currentPageReference().getParameters().get('id');
        naObj=new AccountProgramAttachment__c();
        naObj.isactive__c=true;
        Attachment1=new Attachment();
        rectypeid=Schema.SObjectType.AccountProgramAttachment__c.getRecordTypeInfosByName().get('Attachments').getRecordTypeId();     
    }
   public Pagereference upload()
    {       
        Attachment1.name = filename;
        naObj.name__c=filename;
        naObj.accountId__c=accountid;
        naObj.AttachmentCategory__c=naObj.AttachmentCategory__c;
        naObj.AttachmentTitle__c=attachment1.name;
        naObj.recordtypeid=rectypeid;
        naObj.IsActive__c = naObj.IsActive__c;
        if(filename!=null)
        {
            try
            {      
                insert naObj;
                Attachment1.ParentId = naObj.id;
                insert Attachment1;
                return (new Pagereference('/'+accountid));  
            }
            catch(Exception ex1)
            {
                //delete naObj;
                return null;
            }
        }
        else
        {
            String message1 = Label.AttachmentFileNotChosen;
            Apexpages.addmessage(new ApexPages.Message(ApexPages.severity.FATAL, message1));
        }  
        return null;
    }
   public Pagereference cancel()
    {
        return (new Pagereference('/'+accountid));
    }
}

Hi  all, I am a bit new to salesforce and i succesfully wrote this trigger. But i am lack of ideas on bulkifying it. The below trigger is a basic trigger to check if a contact is linked to a program or opportunity or account.

 

trigger CheckLinktoPrograms on Contact (after update,before delete) {

if(trigger.isupdate){
List<ProgramContactRole__c> lstConRole = new List<ProgramContactRole__c>();
List<AccountContactRole> lstConRole3 = new List<AccountContactRole>();
List<OpportunityContactRole> lstConRole4 = new List<OpportunityContactRole>();
Set<Id> setContactId = new Set<Id>();

for(Contact c:trigger.new){
setContactId.add(c.id);
}
lstConRole=[select id,name,ContactId__c,ProgramId__c,ProgramId__r.name from ProgramContactRole__c where ContactId__c IN:setContactId];
lstConRole3=[select id,ContactId,AccountId,Account.name from AccountContactRole where ContactId IN: setContactId];
lstConRole4=[select id,ContactId,OpportunityId,Opportunity.name from OpportunityContactRole where ContactId IN: setContactId];


for(integer i=0;i<trigger.new.size();i++){

  if(trigger.new[i].Active__c==false ){
 
 for(ProgramContactRole__c pcr:lstConRole){
   if(pcr.ContactId__c==trigger.new[i].id){
      trigger.new[0].addError('Cannot inactivate Contact if its linked to a Program: '+pcr.ProgramId__r.name);
   }
 }
 
 for(AccountContactRole acr:lstConRole3){
   if(acr.ContactId==trigger.new[i].id){
      trigger.new[0].addError('Cannot inactivate Contact if its linked to an Account: '+acr.Account.name);
   }
  }
 
  for(OpportunityContactRole ocr:lstConRole4){
   if(ocr.ContactId==trigger.new[i].id){
      trigger.new[0].addError('Cannot inactivate Contact if its linked to an Opportunity: '+ocr.Opportunity.name);
   }
  }
 
 }
 if(trigger.new[i].To_be_deleted__c == true){
 for(ProgramContactRole__c pcr:lstConRole){
   if(pcr.ContactId__c==trigger.new[i].id){
      trigger.new[0].addError('Cannot mark as delete if its linked to a Program: '+pcr.ProgramId__r.name);
   }
 }
 
 for(AccountContactRole acr:lstConRole3){
   if(acr.ContactId==trigger.new[i].id){
      trigger.new[0].addError('Cannot mark as delete if its linked to an Account: '+acr.Account.name);
   }
  }
 
  for(OpportunityContactRole ocr:lstConRole4){
   if(ocr.ContactId==trigger.new[i].id){
      trigger.new[0].addError('Cannot mark as delete if its linked to an Opportunity: '+ocr.Opportunity.name);
   }
  }
  }
}
}

if(trigger.isdelete){
List<AccountContactRole> lstConRole1 = new List<AccountContactRole>();
List<OpportunityContactRole> lstConRole2 = new List<OpportunityContactRole>();
Set<Id> setContactId = new Set<Id>();

for(Contact c:trigger.old){
 setContactId.add(c.id);

 }
lstConRole1=[select id,ContactId,AccountId,Account.name from AccountContactRole where ContactId IN: setContactId];
lstConRole2=[select id,ContactId,OpportunityId,Opportunity.name from OpportunityContactRole where ContactId IN: setContactId];

for(integer i=0;i<trigger.old.size();i++){

  for(AccountContactRole acr:lstConRole1){
    if(acr.ContactId==trigger.old[i].id){
    string accountname='<html><bold>';
    accountname+=acr.Account.name;
    accountname+='</body></html>';
     trigger.old[0].addError('Cannot delete Contact if its linked to an Account: '+accountname+' with a Role ( Contact Role ) ');
   }
  }
 
  for(OpportunityContactRole ocr:lstConRole2){
    if(ocr.ContactId==trigger.old[i].id){
     trigger.old[0].addError('Cannot delete Contact if its linked to an Opportunity: '+ocr.Opportunity.name+' with a Role ( Contact Role ) ');
   }
  }
 
 }
 
 
}


}

 

Hi  all, I am a bit new to salesforce and i succesfully wrote this trigger. But i am lack of ideas on bulkifying it. The below trigger is a basic trigger to check if a contact is linked to a program or opportunity or account.

 

trigger CheckLinktoPrograms on Contact (after update,before delete) {

if(trigger.isupdate){
List<ProgramContactRole__c> lstConRole = new List<ProgramContactRole__c>();
List<AccountContactRole> lstConRole3 = new List<AccountContactRole>();
List<OpportunityContactRole> lstConRole4 = new List<OpportunityContactRole>();
Set<Id> setContactId = new Set<Id>();

for(Contact c:trigger.new){
setContactId.add(c.id);
}
lstConRole=[select id,name,ContactId__c,ProgramId__c,ProgramId__r.name from ProgramContactRole__c where ContactId__c IN:setContactId];
lstConRole3=[select id,ContactId,AccountId,Account.name from AccountContactRole where ContactId IN: setContactId];
lstConRole4=[select id,ContactId,OpportunityId,Opportunity.name from OpportunityContactRole where ContactId IN: setContactId];


for(integer i=0;i<trigger.new.size();i++){

  if(trigger.new[i].Active__c==false ){
 
 for(ProgramContactRole__c pcr:lstConRole){
   if(pcr.ContactId__c==trigger.new[i].id){
      trigger.new[0].addError('Cannot inactivate Contact if its linked to a Program: '+pcr.ProgramId__r.name);
   }
 }
 
 for(AccountContactRole acr:lstConRole3){
   if(acr.ContactId==trigger.new[i].id){
      trigger.new[0].addError('Cannot inactivate Contact if its linked to an Account: '+acr.Account.name);
   }
  }
 
  for(OpportunityContactRole ocr:lstConRole4){
   if(ocr.ContactId==trigger.new[i].id){
      trigger.new[0].addError('Cannot inactivate Contact if its linked to an Opportunity: '+ocr.Opportunity.name);
   }
  }
 
 }
 if(trigger.new[i].To_be_deleted__c == true){
 for(ProgramContactRole__c pcr:lstConRole){
   if(pcr.ContactId__c==trigger.new[i].id){
      trigger.new[0].addError('Cannot mark as delete if its linked to a Program: '+pcr.ProgramId__r.name);
   }
 }
 
 for(AccountContactRole acr:lstConRole3){
   if(acr.ContactId==trigger.new[i].id){
      trigger.new[0].addError('Cannot mark as delete if its linked to an Account: '+acr.Account.name);
   }
  }
 
  for(OpportunityContactRole ocr:lstConRole4){
   if(ocr.ContactId==trigger.new[i].id){
      trigger.new[0].addError('Cannot mark as delete if its linked to an Opportunity: '+ocr.Opportunity.name);
   }
  }
  }
}
}

if(trigger.isdelete){
List<AccountContactRole> lstConRole1 = new List<AccountContactRole>();
List<OpportunityContactRole> lstConRole2 = new List<OpportunityContactRole>();
Set<Id> setContactId = new Set<Id>();

for(Contact c:trigger.old){
 setContactId.add(c.id);

 }
lstConRole1=[select id,ContactId,AccountId,Account.name from AccountContactRole where ContactId IN: setContactId];
lstConRole2=[select id,ContactId,OpportunityId,Opportunity.name from OpportunityContactRole where ContactId IN: setContactId];

for(integer i=0;i<trigger.old.size();i++){

  for(AccountContactRole acr:lstConRole1){
    if(acr.ContactId==trigger.old[i].id){
    string accountname='<html><bold>';
    accountname+=acr.Account.name;
    accountname+='</body></html>';
     trigger.old[0].addError('Cannot delete Contact if its linked to an Account: '+accountname+' with a Role ( Contact Role ) ');
   }
  }
 
  for(OpportunityContactRole ocr:lstConRole2){
    if(ocr.ContactId==trigger.old[i].id){
     trigger.old[0].addError('Cannot delete Contact if its linked to an Opportunity: '+ocr.Opportunity.name+' with a Role ( Contact Role ) ');
   }
  }
 
 }
 
 
}


}

I am trying to use for update in the SOQL query for territory object. I recieve the below error

"SObject type does not allow locking rows"

Where as i tried to use the for update keyword on account and contacts and it did work. is there any limitation to use the FOR UPDATE on territories.
Hi I have created a textarea long field. when i enterd data in this without enter it is showing in one line. how can i add line break without press enter so it should show on page with line break.

plz help!
Hello!

Can someone help me with a trigger? I have it together, but there is an issue with the attachment part. It is not attaching. Here is the trigger:

trigger CreateContractDocSignComp on dsfs__DocuSign_Status__c (after update)
{
    map<id,id> testmap = new map<id,id>();
    
     list <attachment> attach = new list<attachment>();
    List<Contract> ctr = new List<Contract>();
    
      for(dsfs__DocuSign_Status__c dsfs : Trigger.new)
      {
        if(dsfs.dsfs__Envelope_Status__c == 'Completed')
        {
             Contract c = new Contract(Name = dsfs.Name,
             Status = 'Draft',
             Total_Contract_Value__c = dsfs.Total_Contract_Value__c,
             ContractTerm = Integer.valueOf(dsfs.Contract_Term_months2__c),
             StartDate = dsfs.Contract_Start_Date__c,
             Payment_Status__c = 'Ready to be Invoiced',
             AccountId = dsfs.dsfs__Company__c,
             Opportunity_Name__c = dsfs.dsfs__Opportunity__c,dsfsid__c = dsfs.id);
             ctr.add(c);
        }
      }
      if(ctr.size() > 0)
      {
             System.debug('-ctr------->'+ctr.size());
             insert ctr;
      }
      
        for(contract con : ctr){
         testmap.put(con.dsfsid__c, con.id);
      }
      system.debug('Testmap size is '+testmap.size());
      
      system.debug('query data'+[select id,parentid,body,name from attachment where parentid in :
      testmap.keyset()]);
        for(attachment att : [select id,parentid,body,name from attachment where parentid in : 
      testmap.keyset()]){
      
      if(testmap.containskey(att.parentid)){
      attachment a = new attachment(name=att.name,body=att.body,parentid=testmap.get(att.parentid));
      attach.add(a);
      }
      }
      system.debug('attach is '+attach);
      insert attach;
      
      }

Thanks so much!
Hello

Newbie here. I fear this is a bit basic, but I've been looking for answers for a couple of weeks with no luck. Hopefully this isn't too much to ask of the community.

​I have a custom object and a Visualforce page to edit the records. There is a Due Date field on the object of type Date.  When the record is edited, we need the date that is displayed in the input field to appear either in US format, or according to the user's locale.  We are fine with either. What we always get is yyyy-mm-dd. We want mm/dd/yyyy. Have read that Visualforce is supposed to respect a user's locale settings.

There are lots of posts around date formatting when you are using apex:outputText and apex:param tags when you are just viewing the data, but that doesn't work when you have an apex:inputField tag.

Here is the code:

<apex:page standardController="MyObject__c" docType="html-5.0" >
 <apex:form>
  <apex:outputPanel layout="block" >
   <apex:outputLabel value="Due Date" for="duedate"/>
   <apex:inputField type="date" showDatePicker="false" styleClass="slds-input" id="duedate" value="{!MyObject__c.Due_Date__c}"/>
  </apex:outputPanel>
 </apex:form>
</apex:page>

​​I have found a few approaches that deal with some custom controller code. But it doesn't seem like it should be that difficult or that much work. Is there some easy formatting option that I am missing? The code above is easy with the simple binding right to the object field. I did some experimenting trying to override the field in a controller extension to format a string using a getter. But I couldn't get that exactly right from the perspective of how to reference the controller extension's methods in the page, let alone what to do during a save operation. But if doing it in controller code is necessary, I'd appreciate some pointers in the right direction. I'm going through Trailhead and some other educational materials as I can, but in parallel have some development requests to address.

Thanks!
Steve​


I created a Note trigger that parses out a particular string from the title and writes it to a custom field within its parent opportunity. I have run several tests within the sandbox environment and the trigger works. When i move it to production however, the trigger does not even fire. i tried both the developer console and the eclipse environment with no luck. i tried starting from scratch and building a simple version of the trigger to make sure no errors would intervene yet the problem still exists. i even built a simular trigger yet on the attachment object and that worked. i checked to see if there are any pre existing triggers on the note object that may screw my trigger up and there arent any. i am now out of options and need asistance

simple  Note Trigger

trigger InvoiceListener on Note (after insert) {
    
  System.Debug('false: ');  

    /*    
 
   
    boolean b = MyMatcher.find();
     System.Debug('here');
    
    if(b == true){
        
    List<Opportunity> oppQuery = null;
       oppQuery = [SELECT Id, accountId FROM Opportunity WHERE Id= :pId ];
    Opportunity op =  oppQuery.get(0);
        System.Debug(op);
        //System.Debug('true: '+MyMatcher.group().substring(1));
        //DateTime d = datetime.now();
    //string timeStr = d.format('MMMMM dd, yyyy');
        //op.Invoice_Number__c = MyMatcher.group().substring(1);
        //op.Invoice_Date__c = Date.today();
         update op;

   
    }
    else{
      System.Debug('false: '+descrip );  
    }
  */
}

Simular working attachment trigger

trigger AttachmentTest on Attachment (after insert) {
String Title;
Id pId;

for(Attachment att: Trigger.new){
Title=att.Name;
pId=att.ParentId;
}



 

}
Hi, we've just tried to ask salesforce via a case why an Apex job is marked as aborted by User (when each User denies such knowledge) and they seem to think it's a developer request and pointed us here.

Case #11212305
Original request:
Hi, please can you let me know why the batch was "Aborted By User" as no one has aborted a job. Also can you state what the underlying error is - if there is one?
Apex Job Id: 7072000000vWcRV

Since this is an internal issue, I'm assuming the only folks who can help us the Salesforce employees who patrol these boards?

Thanks in advance.
 
20.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
12:01:10.119 (119157280)|EXECUTION_STARTED
12:01:10.119 (119200824)|CODE_UNIT_STARTED|[EXTERNAL]|01pE000000000a1|TerritoryAlignment
12:01:10.161 (161388605)|METHOD_ENTRY|[5]|01pE000000000a1|TerritoryAlignment.TerritoryAlignment()
12:01:10.161 (161466583)|METHOD_EXIT|[5]|TerritoryAlignment
12:01:10.182 (182010006)|METHOD_ENTRY|[8]|01pA0000001oPla|BatchJobUtils.BatchJobUtils()
12:01:10.182 (182084454)|SYSTEM_CONSTRUCTOR_ENTRY|[30]|<init>(Integer)
12:01:10.182 (182137857)|SYSTEM_CONSTRUCTOR_EXIT|[30]|<init>(Integer)
12:01:10.182 (182176141)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182194798)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182208546)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182219542)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182231733)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182242334)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182254105)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182264782)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182276570)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182287244)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182299032)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182309704)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182321427)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182336971)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182349212)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182359748)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182371449)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182382116)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182393862)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182404537)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182429131)|METHOD_EXIT|[8]|BatchJobUtils
12:01:10.183 (183647973)|METHOD_ENTRY|[81]|01pA0000001oPla|BatchJobUtils.setRunning(Id)
12:01:10.185 (185580043)|SOQL_EXECUTE_BEGIN|[120]|Aggregations:0|select Id from Batch_Job__c where Id = :tmpVar1
12:01:10.188 (188411566)|SOQL_EXECUTE_END|[120]|Rows:1
12:01:10.188 (188550692)|SYSTEM_METHOD_ENTRY|[121]|LIST<Batch_Job__c>.isEmpty()
12:01:10.188 (188577929)|SYSTEM_METHOD_EXIT|[121]|LIST<Batch_Job__c>.isEmpty()
12:01:10.188 (188598904)|SYSTEM_METHOD_ENTRY|[122]|LIST<Batch_Job__c>.get(Integer)
12:01:10.188 (188646639)|SYSTEM_METHOD_EXIT|[122]|LIST<Batch_Job__c>.get(Integer)
12:01:10.188 (188740846)|DML_BEGIN|[124]|Op:Update|Type:Batch_Job__c|Rows:1
12:01:10.261 (261542811)|DML_END|[124]
12:01:10.261 (261592724)|METHOD_EXIT|[81]|01pA0000001oPla|BatchJobUtils.setRunning(Id)
12:01:10.261 (261659324)|SYSTEM_METHOD_ENTRY|[83]|System.debug(ANY)
12:01:10.261 (261692205)|USER_DEBUG|[83]|DEBUG|Query : SELECT Id, Customer__c, Territory_Custom__c,  Territory_Custom__r.Name, Territory_Custom__r.Territory_Id__c,  Territory_Custom__r.Group_Id__c,  Account_Share_Id__c, Is_Marked_for_Delete__c  FROM Account_Territory__c  WHERE Account_Share_Id__c = NULL and Is_Marked_for_Delete__c = FALSE  LIMIT 1000000
12:01:10.261 (261701167)|SYSTEM_METHOD_EXIT|[83]|System.debug(ANY)
12:01:10.272 (272605280)|METHOD_ENTRY|[12]|01pA0000001oPmU|CodeSettingUtils.CodeSettingUtils()
12:01:10.272 (272702512)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272753205)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272778685)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272794337)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272812314)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272826579)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272844713)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272858708)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272876043)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272889717)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272905891)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272919455)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272938113)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272951908)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272969423)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272983080)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273000441)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273015886)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273032566)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273046930)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273061714)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273075370)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273091822)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273105418)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273121497)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273135824)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273153465)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273167335)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273184698)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273198534)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273215033)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273229240)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273246458)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273260371)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273277037)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273290708)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273313062)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273327845)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273345652)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273359332)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273376709)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273390353)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273410616)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273425681)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273443366)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273457066)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273474137)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273487842)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273510383)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273526564)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273544474)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273558346)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273575787)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273589674)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273620909)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273635533)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273652403)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273666294)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273683891)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273697875)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273713313)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273726754)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273743582)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273757228)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273773558)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273787398)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273805115)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273818970)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273835793)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273849572)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273866608)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273880469)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273895803)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273909396)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273929531)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273943837)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273970773)|METHOD_EXIT|[12]|CodeSettingUtils
12:01:10.275 (275575812)|METHOD_ENTRY|[85]|01pA0000001oPmU|CodeSettingUtils.getTargetID(String)
12:01:10.275 (275808916)|SYSTEM_METHOD_ENTRY|[223]|CommonSettings__c.getInstance(String)
12:01:10.277 (277516687)|SYSTEM_METHOD_EXIT|[223]|CommonSettings__c.getInstance(String)
12:01:10.277 (277580360)|SYSTEM_CONSTRUCTOR_ENTRY|[224]|<init>()
12:01:10.277 (277612047)|SYSTEM_CONSTRUCTOR_EXIT|[224]|<init>()
12:01:10.277 (277621769)|SYSTEM_CONSTRUCTOR_ENTRY|[225]|<init>()
12:01:10.277 (277634537)|SYSTEM_CONSTRUCTOR_EXIT|[225]|<init>()
12:01:10.277 (277672936)|SYSTEM_METHOD_ENTRY|[227]|String.split(String)
12:01:10.277 (277717624)|SYSTEM_METHOD_EXIT|[227]|String.split(String)
12:01:10.280 (280341599)|SOQL_EXECUTE_BEGIN|[229]|Aggregations:0|select Id from User where username IN :tmpVar1
12:01:10.285 (285461038)|SOQL_EXECUTE_END|[229]|Rows:0
12:01:10.285 (285638711)|SYSTEM_METHOD_ENTRY|[230]|LIST<User>.size()
12:01:10.285 (285667057)|SYSTEM_METHOD_EXIT|[230]|LIST<User>.size()
12:01:10.285 (285686223)|METHOD_EXIT|[85]|01pA0000001oPmU|CodeSettingUtils.getTargetID(String)
12:01:10.285 (285726722)|SYSTEM_METHOD_ENTRY|[85]|com.salesforce.api.interop.apex.bcl.DatetimeMethods.now()
12:01:10.285 (285749377)|SYSTEM_METHOD_EXIT|[85]|com.salesforce.api.interop.apex.bcl.DatetimeMethods.now()
12:01:10.285 (285773459)|SYSTEM_METHOD_ENTRY|[85]|String.valueOf(Object)
12:01:10.285 (285795208)|SYSTEM_METHOD_EXIT|[85]|String.valueOf(Object)
12:01:10.294 (294655813)|METHOD_ENTRY|[14]|01pA0000001oPmk|EmailUtils.EmailUtils()
12:01:10.294 (294682503)|METHOD_EXIT|[14]|EmailUtils
12:01:10.296 (296055727)|METHOD_ENTRY|[85]|01pA0000001oPmk|EmailUtils.sendEmail(LIST<String>, String, String, Boolean, LIST<Messaging.EmailFileAttachment>, Boolean)
12:01:10.296 (296089329)|SYSTEM_METHOD_ENTRY|[48]|LIST<String>.size()
12:01:10.296 (296134515)|SYSTEM_METHOD_EXIT|[48]|LIST<String>.size()
12:01:10.296 (296149751)|METHOD_EXIT|[85]|01pA0000001oPmk|EmailUtils.sendEmail(LIST<String>, String, String, Boolean, LIST<Messaging.EmailFileAttachment>, Boolean)
12:01:10.296 (296177294)|SYSTEM_METHOD_ENTRY|[90]|Database.getQueryLocator(String)
12:01:10.302 (302054710)|SOQL_EXECUTE_BEGIN|[90]|Aggregations:0|SELECT Id, Customer__c, Territory_Custom__c,  Territory_Custom__r.Name, Territory_Custom__r.Territory_Id__c,  Territory_Custom__r.Group_Id__c,  Account_Share_Id__c, Is_Marked_for_Delete__c  FROM Account_Territory__c 
12:31:17.661 (1807661545838)|EXCEPTION_THROWN|[90]|System.UnexpectedException: Internal Salesforce.com Query Error
12:31:17.661 (1807661671103)|SYSTEM_METHOD_EXIT|[90]|Database.getQueryLocator(String)
12:31:17.661 (1807661743998)|FATAL_ERROR|System.UnexpectedException: Internal Salesforce.com Query Error

Class.TerritoryAlignment.start: line 90, column 1
12:31:17.952 (1807661876825)|CUMULATIVE_LIMIT_USAGE
12:31:17.952|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 0 out of 200
  Number of query rows: 0 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 0 out of 150
  Number of DML rows: 0 out of 10000
  Maximum CPU time: 0 out of 60000
  Maximum heap size: 0 out of 12000000
  Number of callouts: 0 out of 0
  Number of Email Invocations: 0 out of 10
  Number of future calls: 0 out of 0
  Number of Mobile Apex push calls: 0 out of 10

12:31:17.952|CUMULATIVE_LIMIT_USAGE_END

12:31:17.661 (1807661912023)|CODE_UNIT_FINISHED|TerritoryAlignment

I need to refer a custom settting field in the Javascript button.

How do we refer custo setting values in Java script button code

I need to refer a custom settting field in the Javascript button.

How do we refer custo setting values in Java script button code

Can anybody help me in executing the below batch class using annonomous apex

 

global class batchUpdateAccounts implements Database.Batchable<sObject>,Database.Stateful{

global Database.QueryLocator start(Database.BatchableContext bc){

    return database.getQuerylocator('select id,Category__c,Family__c from Account');
}

global void execute(Database.BatchableContext bc, List<SObject> scope) {
    
        List<Account> accs = (List<Account>)scope;
        List<Account> accsToUpdate = new List<Account>();
        List<Global_families__c> gfslst = new List<Global_families__c>();
        gfslst = [select Is_Global__c, Name from Global_families__c];
 
        for(Account acunts : accs){
        for(Global_families__c lstglobal: gfslst ){
        if(acunts.Family__c == lstglobal.Name && lstglobal.Is_Global__c == TRUE){
        Acunts.Family__c = 'Global';
        accsToUpdate.add(acunts);
        }
        }
        }
        
        update accsToUpdate;
        
       
}

global void finish(Database.BatchableContext bc){
        

}

}

HI

 

Iam looking to add an error when customerNote__c object records is edited only when createdBy= UserInfo.getuserId

 

 

 

 
  • August 23, 2013
  • Like
  • 0

I am having a view state error on my vf page.

Below the controller code which i believe is causing the eror. Can anyone help me which part of the code is causing this error

 

public class Team_Attach_ACL
{
    id accountid,rectypeid;
    public AccountProgramAttachment__c naObj{set; get;}
   public Attachment attachment1{set; get;}
    public string filename { get;set;}
    public Team_Attach_ACL(ApexPages.StandardController controller)
    {
        accountid=system.currentPageReference().getParameters().get('id');
        naObj=new AccountProgramAttachment__c();
        naObj.isactive__c=true;
        Attachment1=new Attachment();
        rectypeid=Schema.SObjectType.AccountProgramAttachment__c.getRecordTypeInfosByName().get('Attachments').getRecordTypeId();     
    }
   public Pagereference upload()
    {       
        Attachment1.name = filename;
        naObj.name__c=filename;
        naObj.accountId__c=accountid;
        naObj.AttachmentCategory__c=naObj.AttachmentCategory__c;
        naObj.AttachmentTitle__c=attachment1.name;
        naObj.recordtypeid=rectypeid;
        naObj.IsActive__c = naObj.IsActive__c;
        if(filename!=null)
        {
            try
            {      
                insert naObj;
                Attachment1.ParentId = naObj.id;
                insert Attachment1;
                return (new Pagereference('/'+accountid));  
            }
            catch(Exception ex1)
            {
                //delete naObj;
                return null;
            }
        }
        else
        {
            String message1 = Label.AttachmentFileNotChosen;
            Apexpages.addmessage(new ApexPages.Message(ApexPages.severity.FATAL, message1));
        }  
        return null;
    }
   public Pagereference cancel()
    {
        return (new Pagereference('/'+accountid));
    }
}

Hi  all, I am a bit new to salesforce and i succesfully wrote this trigger. But i am lack of ideas on bulkifying it. The below trigger is a basic trigger to check if a contact is linked to a program or opportunity or account.

 

trigger CheckLinktoPrograms on Contact (after update,before delete) {

if(trigger.isupdate){
List<ProgramContactRole__c> lstConRole = new List<ProgramContactRole__c>();
List<AccountContactRole> lstConRole3 = new List<AccountContactRole>();
List<OpportunityContactRole> lstConRole4 = new List<OpportunityContactRole>();
Set<Id> setContactId = new Set<Id>();

for(Contact c:trigger.new){
setContactId.add(c.id);
}
lstConRole=[select id,name,ContactId__c,ProgramId__c,ProgramId__r.name from ProgramContactRole__c where ContactId__c IN:setContactId];
lstConRole3=[select id,ContactId,AccountId,Account.name from AccountContactRole where ContactId IN: setContactId];
lstConRole4=[select id,ContactId,OpportunityId,Opportunity.name from OpportunityContactRole where ContactId IN: setContactId];


for(integer i=0;i<trigger.new.size();i++){

  if(trigger.new[i].Active__c==false ){
 
 for(ProgramContactRole__c pcr:lstConRole){
   if(pcr.ContactId__c==trigger.new[i].id){
      trigger.new[0].addError('Cannot inactivate Contact if its linked to a Program: '+pcr.ProgramId__r.name);
   }
 }
 
 for(AccountContactRole acr:lstConRole3){
   if(acr.ContactId==trigger.new[i].id){
      trigger.new[0].addError('Cannot inactivate Contact if its linked to an Account: '+acr.Account.name);
   }
  }
 
  for(OpportunityContactRole ocr:lstConRole4){
   if(ocr.ContactId==trigger.new[i].id){
      trigger.new[0].addError('Cannot inactivate Contact if its linked to an Opportunity: '+ocr.Opportunity.name);
   }
  }
 
 }
 if(trigger.new[i].To_be_deleted__c == true){
 for(ProgramContactRole__c pcr:lstConRole){
   if(pcr.ContactId__c==trigger.new[i].id){
      trigger.new[0].addError('Cannot mark as delete if its linked to a Program: '+pcr.ProgramId__r.name);
   }
 }
 
 for(AccountContactRole acr:lstConRole3){
   if(acr.ContactId==trigger.new[i].id){
      trigger.new[0].addError('Cannot mark as delete if its linked to an Account: '+acr.Account.name);
   }
  }
 
  for(OpportunityContactRole ocr:lstConRole4){
   if(ocr.ContactId==trigger.new[i].id){
      trigger.new[0].addError('Cannot mark as delete if its linked to an Opportunity: '+ocr.Opportunity.name);
   }
  }
  }
}
}

if(trigger.isdelete){
List<AccountContactRole> lstConRole1 = new List<AccountContactRole>();
List<OpportunityContactRole> lstConRole2 = new List<OpportunityContactRole>();
Set<Id> setContactId = new Set<Id>();

for(Contact c:trigger.old){
 setContactId.add(c.id);

 }
lstConRole1=[select id,ContactId,AccountId,Account.name from AccountContactRole where ContactId IN: setContactId];
lstConRole2=[select id,ContactId,OpportunityId,Opportunity.name from OpportunityContactRole where ContactId IN: setContactId];

for(integer i=0;i<trigger.old.size();i++){

  for(AccountContactRole acr:lstConRole1){
    if(acr.ContactId==trigger.old[i].id){
    string accountname='<html><bold>';
    accountname+=acr.Account.name;
    accountname+='</body></html>';
     trigger.old[0].addError('Cannot delete Contact if its linked to an Account: '+accountname+' with a Role ( Contact Role ) ');
   }
  }
 
  for(OpportunityContactRole ocr:lstConRole2){
    if(ocr.ContactId==trigger.old[i].id){
     trigger.old[0].addError('Cannot delete Contact if its linked to an Opportunity: '+ocr.Opportunity.name+' with a Role ( Contact Role ) ');
   }
  }
 
 }
 
 
}


}

 

Hi,

 

I couldnot able to login to offline edition of salesforce. Whenever I click on login, IE is open and getting below msg.

 

Internet Explorer restricted this webpage from running scripts or ActiveX Controls.

 

Please help.

 

Sanj