• ASIF ALI
  • NEWBIE
  • 55 Points
  • Member since 2019
  • Salesforce Developer
  • Miri Infotech

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 15
    Replies
Hello,
I am new to salesforce and I would like to know how to create custom button to update record's field value on click.
Should I use lightning component + apex code or is it possible achieve it without code?
Example - what I am trying to achieve:
FieldName:  Times clicked
FieldValue = 0 + 1 time clicked // sObject_c.TimesClicked++
RollUp Contact to Account.
Account has Total_Amt__c field, Customer has Amount__c(Currency) field. 
Total_Amt__c field should show all sum of all values of Amount__c field of all chield reccord
(please explain critical lines in code)
Hi,

I am executing Batch Apex this type of error showing can you please solve my problem
(Line: 2, Column: 10
Method does not exist or incorrect signature: void executeBatch(BatchApexExample) from the type Database.
this is my code:

global class BatchApexExample implements DataBase.Batchable<sObject>
{
    global String query = 'oppartunaty';
  global DataBase.QueryLocator start(DataBase.BatchableContext bc)
    {
        
        string query='select id,name,amount, Discription from oppartunaty';
        return Database.getQueryLocator(query);
    }
        
     global void execute(DataBase.BatchableContext bc, List<oppartunaty> records){
    
        
        for(oppartunaty  opp: records)
        {
            opp.amount=2000;
            opp.Discription='this my first batch Apex';
                
        }
         update records;
       
        // process each 
    }
    global void finish(Database.BatchableContext bc){
        //procee    
    }
     
}
Hello,
I am new to salesforce and I would like to know how to create custom button to update record's field value on click.
Should I use lightning component + apex code or is it possible achieve it without code?
Example - what I am trying to achieve:
FieldName:  Times clicked
FieldValue = 0 + 1 time clicked // sObject_c.TimesClicked++
Hi All,
Can anybody please tell me how to Pass parameter of One Page To Another in Visualforce, like...
Account object has certain input fields in first Vf page, when we input some data and click on button. List of values of these input field is shown in another Vf page.
help me with simple code.
how to write the test class for trigger
Can anyone help me please? I am unable to login to Trailhead/ Blazer CommunitySalesForce Error Message Screen Shot
Below is the part of my class. these are the wrapper class.
 public class ASMWrapper{
        @auraEnabled public User userObj{get;set;}
        @auraEnabled public String RoleName{get;set;}
        @auraEnabled lookUpWrapper selItem{get;set;}
    }
    public class lookUpWrapper{
        public String objName {get;set;}
        public String text{get;set;}
        public String val{get;set;}
        public Object ObjRecord{get;set;}
    }

Below ti the method which convert the json to string.

 public class ASMWrapper{
        @auraEnabled public User userObj{get;set;}
        @auraEnabled public String RoleName{get;set;}
        @auraEnabled lookUpWrapper selItem{get;set;}
    }
    public class lookUpWrapper{
        public String objName {get;set;}
        public String text{get;set;}
        public String val{get;set;}
        public Object ObjRecord{get;set;}
    }

this method is getting the JSON. please help me parse it.

public static void  newAccRecord(String asmHierarchy){
        system.debug('string JSON '+asmHierarchy);
        System.debug('jason der' + JSON.deserializeUntyped(asmHierarchy));
        /*if(asmHierarchy.size() >0){
            for(object obj : asmHierarchy){
                system.debug('obj '+obj);
                //ASMWrapper asm = (ASMWrapper)obj;
                //system.debug('User ==> '+asm.asmObj.userObj);
            }
            System.debug(' ASMWrapper DONE @@@ '+asmHierarchy);
            System.debug('size of role '+asmHierarchy.size());
        }*/
       
    }
This is my FIRST trigger.
I want to create an "Event" after "Time Off Request" is Approved.
After approving, the following error message is showing...

User-added image

Here is my trigger:

trigger TRTimeOffAfterUpdate on Time_Off_Request__c (after update) {

for (Time_Off_Request__c toEvent : Trigger.new) {
    if(toEvent.Status__c=='Approved'){
   // Event event = new Event
   Event ev= new Event 
   (
        OwnerId = toEvent.CreatedById,
        StartDateTime = toEvent.First_Day_Off__c,
        EndDateTime = toEvent.End_Time_Off__c,
        Subject = toEvent.Type__c,
        Description =  toEvent.Comments__c,
        ShowAs = 'Out of Office'
    );
    insert ev ;             
}
}
}

Any idea what is wrong?
Thanks
Account object has Acc_Satus__c  Field and Contact Object has Con_Status__c Field.
both Acc_Satus__c, Con_Status__c are picklist field with values: Open, Closed, InProgress.
Account Record Has Three Child Contact Records
1. Whenever Account record field is updated with Acc_Satus__c Piclist field as 'Closed', all Contact Con_Status__c field should be 'Closed'.
2. if Con_Status__c field in all three Contact record is selected as 'Closed' Account picklist Acc_Satus__c Field Should be 'Closed'.
give me a code with Helper class
RollUp Contact to Account.
Account has Total_Amt__c field, Customer has Amount__c(Currency) field. 
Total_Amt__c field should show all sum of all values of Amount__c field of all chield reccord
(please explain critical lines in code)
I want to create a trigger on Note object.
When a new note is created it will update a custom field on Case object with LastModifiedDate of New note.

My code is :

trigger UpdateLastModifiedDate on Note(after insert) {
    
     List<Case> caseUpdate = new List<Case>();
    for(Note n : Trigger.new){
        if(n.ParentId != null && n.ParentId.getSObjectType() == Case.sObjectType){
            Case cas=new Case(Id=n.parentId,Last_Modified_Date1__c=n.CreatedDate);
            caseUpdate.add(cas);

       } 
    }
    
    if(caseUpdate.size()>0){
        update caseUpdate;
    }
}
Can anyone explain Difference between Process Builder and Flows with example ? 
Thanks in Advance. 
AJ
Hi All,

I want to display number of contacts associated with an account using triggers.

for this I had created a lookup field like noofcontacts__c in account  object. and Wrote code as

trigger numberofcontacts on contact(after insert, after update, after delete) {
    Map<Id, List<Contact>> AcctContactList = new Map<Id, List<Contact>>();
    Set<Id> AcctIds = new Set<Id>();   
    List<schema.Account> AcctList = new List<schema.Account>();
    List<schema.Contact> ConList = new List<schema.Contact>();
   
    if(trigger.isInsert || trigger.isUPdate) {
        for(Contact Con : trigger.New) {
            if(String.isNotBlank(Con.AccountId)){
                AcctIds.add(Con.AccountId); 
            }  
        } 
    }
   
    if(trigger.isDelete) {
        for(Contact Con : trigger.Old) {
            AcctIds.add(Con.AccountId);    
        } 
    }          
   
    if(AcctIds.size() > 0){
        ConList = [SELECT Id, AccountId FROM Contact WHERE AccountId IN : AcctIds];
       
        for(Contact Con : ConList) {
            if(!AcctContactList.containsKey(Con.AccountId)){
                AcctContactList.put(Con.AccountId, new List<Contact>());
            }
            AcctContactList.get(Con.AccountId).add(Con);     
        }                          
      
           
        AcctList = [SELECT noofContacts__c FROM Account WHERE Id IN : AcctIds];
        for(Account Acc : AcctList) {
            List<schema.Contact> ContList = new List<schema.Contact>();
            ContList = AcctContactList.get(Acc.Id);
            Acc.Number_of_Contacts__c = ContList.size();
        }   
       
      
        update AcctList;   
    }

}
 I am   getting an error as "Variable doesnot exist:id".

Kindly support and suggest.

Thanks