• Ankit Khurana
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 7
    Replies

there is custom field Amount Iin contact and account.i need to find roll up of sum of all contact amount in account amount also any changes in contact should make changes in the amount of account.Since roll up can only be made in master-detail and account -contact are lookup .therefore i have written a trigger using aggregate function,but its not working Please help

trigger accountupdate on Contact (after insert,after update,after delete)
{
for (Contact con:trigger.new)
{
Account ac=[Select Amount__c,Account.name from Account where Account.name =:con.Account.name];
AggregateResult[] amountsum=[Select SUM(Amount__c)s from Contact where Account.name=:con.Account.name];
object acc=amountsum[0].get('s');
system.debug('aaaa'+acc);
//ac.Amount__c=acc[0];
// update ac;
}
}

Can anyone help me how to upload new from one salesforce to another...

what are need to do exactly is:....there are 10 records each in Account,lead ,opportunity and cases and i have to upload them to another salesforce...how to do that..?

 

Scenerio is

" Whenever a new case is created, Assign case to most free user (who have minimum no of cases). There is a counter on user which show that how many cases has been assigned to an user.  Based on this counter cases will be assigned to users.                                                    

 When a case status is being changed to closed, the case counter on user will decrease by 1, and when a case is assigned to a user the case counter on user will be increased by 1."

 

Help me....

i did like this but not working fine.....

1.created a trigger

trigger assignUser on Case (before insert,after insert)
{

        String userid= '';
        Map<id,user> userMap= new Map<id,user>([select id, Assigned_Cases__c from User ORDER BY Assigned_Cases__c ASC LIMIT 1]);
       
        if(Trigger.isInsert && Trigger.isBefore)
        {
                    for(Case c : Trigger.new)
                    {
                            System.Debug('Processing ' + c.CaseNumber);
                            Caseassignment.makeCallout(c.CaseNumber);
                            //c.Owner=userid;
                    }
                   update userMap.values();
                  
        }
}

 

Query:how to insert userid i obtained from below class to the c.owner field so hat respective owner should be asigned to particular case because case is lookup of owner......

 

2.Class to use future method

public class Caseassignment
{
   
@Future(callout=true)
    public static void makecallout(String CaseNumber)
               {
                            String userid= '';
                            Map<id,user> userMap= new Map<id,user>([select id,Name, Assigned_Cases__c from User ORDER BY Assigned_Cases__c ASC LIMIT 1]);
                            List<User> uu = userMap.values();
                            userid= uu[0].id;
                           
                            user up = userMap.get(userid);
                            up.Assigned_Cases__c ++;
                            userMap.put(userid,up);
                           
                }
    }

query:

how to perform below functionality in above class

"  When a case status is being changed to closed, the case counter on user will decrease by 1, and when a case is assigned to a user the case counter on user will be increased by 1."

 

"There is a text box on case page layout. User can enter text into it. Whenever user type <today> in the text, while saving the case, today should be replaced by today’s date" 

 

 

I tried this trigger but it works only when new case is created..but donot when case is edited.

trigger dateconvert on Case (after insert)
{
 
  for(Case case1:System.Trigger.new)
  {
  Case ca=[select Enter_text__c from Case where CaseNumber =:case1.CaseNumber  ];
  date myDate = date.today();
  String abc = myDate .format();
  String NewEntry=ca.Enter_text__c.replaceAll('today',abc);
    ca.Enter_text__c=NewEntry;
  update ca;
  }
    
 
}

Hi... 

Please let me know..how to update a custom field in case object {say enter_text_c} on save click such that if we there is an text 'today' in the field it should be converted to today's date..

there is custom field Amount Iin contact and account.i need to find roll up of sum of all contact amount in account amount also any changes in contact should make changes in the amount of account.Since roll up can only be made in master-detail and account -contact are lookup .therefore i have written a trigger using aggregate function,but its not working Please help

trigger accountupdate on Contact (after insert,after update,after delete)
{
for (Contact con:trigger.new)
{
Account ac=[Select Amount__c,Account.name from Account where Account.name =:con.Account.name];
AggregateResult[] amountsum=[Select SUM(Amount__c)s from Contact where Account.name=:con.Account.name];
object acc=amountsum[0].get('s');
system.debug('aaaa'+acc);
//ac.Amount__c=acc[0];
// update ac;
}
}

1.i need to get id of 20 latest created cases.

how to create a grid on vf page ......

1.grid need to show which case has been assigned to whom(loged in users)

2. grid need to contains  maximum of 20 latest  cases.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

"There is a text box on case page layout. User can enter text into it. Whenever user type <today> in the text, while saving the case, today should be replaced by today’s date" 

 

 

I tried this trigger but it works only when new case is created..but donot when case is edited.

trigger dateconvert on Case (after insert)
{
 
  for(Case case1:System.Trigger.new)
  {
  Case ca=[select Enter_text__c from Case where CaseNumber =:case1.CaseNumber  ];
  date myDate = date.today();
  String abc = myDate .format();
  String NewEntry=ca.Enter_text__c.replaceAll('today',abc);
    ca.Enter_text__c=NewEntry;
  update ca;
  }
    
 
}

 Can anyone help me in doing this...  

  Extract   data from one salesforce Org (at least 10 records per object) and upload the same into other Salesforce Org for following objects.

I          For   Objects Account, contact, lead, opportunity

II           and  two custom object Object A (Parent) and Object B (child) having master detail relationship .both these objects contain  a field of each data type .

Hi... 

Please let me know..how to update a custom field in case object {say enter_text_c} on save click such that if we there is an text 'today' in the field it should be converted to today's date..