• ashish rai
  • NEWBIE
  • 385 Points
  • Member since 2011

  • Chatter
    Feed
  • 15
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 22
    Questions
  • 79
    Replies

Hi

 

I have a field on Agreement which is called ANNUAL RENT.

 

I want to create the same field on the Transaction object which is also ANNUAL RENT and I want the value from the Agreement object to get populated automatically in the Transaction object.

 

Can anyone please help me with this.

 

Thanks

 

Finney

  • April 02, 2012
  • Like
  • 0

Hi,

 

 

I have 2 formulas, each of them tells to the logged user if their are selected in a custom look up : Lookuptouser/Lookuptouser2:

 

 

1: IF( Lookuptouser__r.Id  = $User.Id, "Yes", "No")

2: IF ( Lookuptouser2__r.Id = $User.Id, "Yes", "No")

 

 

How can I put these two formulas in one.

 

So instead of checking individually, I want to check if I am in Lookuptouser OR Lookuptouser2, with a Yes or NO as the answer

  • February 10, 2012
  • Like
  • 0

Hello,

I want to change to Change the format of a CreatedDate.

Now when i put it on a VF it looks like this:

Sat Oct 08 11:07:45 GMT 2011

 

I used valueofGmt, format, and that stuff but nothing worked for me to convert it to this format:

DD.MM.YYYY

 

Thank you in advance.

 

Hi,

 

trigger contactEndDate on Contract (after insert, after update) {
    Contract contract = trigger.new[0];
    list<Contact> contactList = new list<Contact>();
    Date sDate = contract.EndDate;
    Id accID = contract.AccountId;
    if(accID != null) {
        Contact[] con = [select SMA_End_Date__c,Name From Contact where AccountId = :accID];
        if(con != null && con.size() > 0) {
            for (Contact contact : con) {
                contact.SMA_End_Date__c = sDate;
                contactList.add(contact);               
            }
            update contactList;      
        }
    }
}

 

When i try to invoke the above trigger i am getting this error

 

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger contactEndDate caused an unexpected exception, contact your administrator: contactEndDate: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 003L0000002xSxCIAU; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, ContactObj: []: Trigger.contactEndDate: line 13, column 13

 

Can anyone please help me to resolve this problem?

 

Thanks and Regards

Hari G S

 

Helle, i want to build the testmethod apex class for a apex class trigger, but i dont obtain any result.

 

trigger t on Account (after update) {
      for (Account a : Trigger.new) {
      List<Contact> contactdata = [Select Id, AccountId, Name From Contact where AccountId = :a.Id];
if(contactdata.size()>0) {
List<User> userdata = [Select Id, ContactId From User where ContactId = :contactdata.get(0).Id];
if(userdata.size()>0) {
userdata.get(0).accspot__c = a.Spot_lead_time__c;
userdata.get(0).accstory__c = a.Storyboard_lead_time__c;
update userdata.get(0);
}
}
}
}

 

 

Thanks!!!

  • October 04, 2011
  • Like
  • 0

i want to write a update trigger. what is the best practise approch to fire this update trigger only for the first time?

Hi All

 

I need to get a list of days between a start and end date, as a test i've tried using the following but it doesn't produce any results (no error message either). Any ideas how i can achieve this?

 

Date startDate = date.newinstance(2010, 01, 01);
Date endDate = date.newinstance(2011, 01, 01);
               
        for (Date d = startDate; d.isSameDay(endDate) ; d.addDays(1))
        {
            system.debug(d);
        }

 Thanks for any ideas.

Paul

  • September 23, 2011
  • Like
  • 0

Hi Guys,

 

We have two classes System and Datetime in apex. Both provides static now  method. I want to know what is difference between now method from System and Datetime class. I would also like to know broad idea of System class and when to use it?

 

 

 

Thanks

HI all,

 

        In visualforce we can write like this.

<apex:inputField value="{!CreateAnEvent.Event_title__c}" style="width:250px" id="Eventinfo_title"/>.

 

Is it possible to concatenate another variable which is defined in apex class to the value attribute in <apex:inputField>. Its a very urgent requirement.Please help me. 

 

My requirement is, I will select few field names randomly  of an Object in apex class.I need to display these fields dynamically in visualforce page. How can I achieve this.

 

If you need any other information please let me know.

 

Thanks,

Naresh B                   

 

I have written the following test method to test a Trigger on the FeedItem object (to prevent deletion through Chatter):

 

@isTest
private class deleteBlockerTest{
        static testMethod void deleteBlockerTest() {
           
            //Set up the User record.
            User u = new User(Firstname='Test',LastName='Test',Username='test.test@test.com.globalsb',Email='test.test@test.com',Alias='ttest',CommunityNickname='test.test',TimeZoneSidKey='GMT',LocaleSidKey='en_GB',EmailEncodingKey='ISO-8859-1',ProfileId='00e50000000yyaB',LanguageLocaleKey='en_US');
            insert u;
           
            //Set up the UserFeed record.
            FeedItem fi = new FeedItem(Body='Test text for Item Body',ParentId=u.Id);
            upsert fi;
                                                        
            //Cause the Trigger to execute.
            delete fi;
           
            //Verify that the results are as expected.
            FeedItem fi2 = [select Id,IsDeleted from FeedItem where id = :fi.Id];
            System.assertEquals(fi2.isdeleted,false);
            }
        }

 

However, I am getting the following error message:

 

System.DmlException: Delete failed. First exception on row 0 with id 0D5R0000002Lkp1KAC; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, deleteBlocker: execution of BeforeDelete caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.deleteBlocker: line 2, column 20: []

 

Can someone please advise me what I am doing wrong?

 

Thanks,

 

Marco

 

Hello Developer!

 

 

 I am littlebit confused how to write testmethod  for particular trigger.

And, Done some part of coding in testmethod but it gives only 36% code coverage but i need atleast 75%

 

what to write on code in testmethod to make atleast 75%.

 

Test method:

 

@istest
private class leave_testmethod
{
static testmethod void leaveprocess_testmethod()
{
   integer totalDaysFinal;
   Leave_Process__c leavetest= new Leave_Process__c();
   
test.startTest();

insert leavetest;


test.stopTest();


}
}

 

Trigger:

 

trigger trgLeaveAppBeforeInsert on Leave_Process__c(before insert) {
      
    Date startDate, endDate;
    Integer startDayofYear, endDayofYear, totalDaysFinal,totalDaysInitial;
    if(trigger.isInsert){
        for(Leave_Process__c obj : Trigger.new){
          
          
            startDate = obj.manage_packapp__Start_Date__c;
            endDate = obj.manage_packapp__End_date__c;
            // remainingLeave = obj.managed_Appsamp_Remaining_Leave_c;
          
            if(startDate.year() == endDate.year()){
              
                totalDaysInitial = endDate.dayOfYear() - startDate.dayOfYear()+1;
                totalDaysFinal = totalDaysInitial;
               
               DateTime startEndDate;
                for(integer i = 0; i< totalDaysFinal; i++){
                  
                    for (Holiday hObj : [Select activityDate from Holiday]){
                      
                       if(startDate.addDays(i) == hObj.activityDate){
                          
                            totalDaysFinal--;
                        }                      
                    }
                  
                    
                   
                }
                 // Code for calculating weekend days
                for(integer j = 0; j< totalDaysFinal; j++)
                {
                    startEndDate = startDate.addDays(j);
                    if(startEndDate.format('E')=='Sat'|startEndDate.format('E')=='Sun')
                    {
                        totalDaysFinal--;
                    }
                                    
                }
            }
            obj.manage_packapp__leaveprocess__c = totalDaysFinal;
           // obj.managed_Appsamp_Remaining_Leave_c=obj.managed_Appsamp_Remaining_Leave_c - totalDaysFinal;
          
        }

  }
}

 

 

plz help us out.

 

Thanks & Regards

Ashish Agrawal

i have Health_History_del__c in account (sandbox ) but when i deploy it to production i am able to see the field but through the SOQL query i am not able to fetch the value in force .com ide even that field does not show in my  vf page

 

what is the possible problem in that

 

Hello everybody , I really nead some help on how to create a test class in order to bring a Trigger over the prodution instance..

Here is it :


trigger monTrigger on Dossier_P_re__c(before update){
  
    List<Case> op= new  List<Case>();
   
    Set<Id> ChampReq = new Set<Id>();
   
    for(Dossier_P_re__c dos : Trigger.new)
    {
            ChampReq.add(dos.Id); // L'Id de l'objet Dossier_P_re__c dans le ticket Principal    
    }
                
    if(System.Trigger.isUpdate)
    {
        try
        {
        op=[select Dossier_P_re__c, Status,IsClosed from Case where Dossier_P_re__c In: ChampReq];
     
        }
        catch(Exception e){ System.debug('Exception' + e);
        }
    
         for(Dossier_P_re__c dosDeux : Trigger.new)
         {
            if(dosDeux.Statut__c =='Clos')
            {
                    for(Case cas : op)
                    {
                     cas.Status='Clos';
                     update(cas);
                                         
                    }    
                   
            }
               
       } 
     }                 
   
}

 

Really  need some help !  Thanks in advance

  • September 16, 2011
  • Like
  • 0

Can anybody tell me how to add calendar on visualforce page... 

  • September 15, 2011
  • Like
  • 0

On my quote object I have a visualforce page and a trigger creates new records in several different record types, but I want to use the standard new quote record functionality for one record type. When I try to save a record wit the the standard fuctionality, I recieve the following error message:

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger QuoteNumberUpdate caused an unexpected exception, contact your administrator: QuoteNumberUpdate: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.QuoteNumberUpdate: line 22, column 14

 Below is my code:

trigger QuoteNumberUpdate on Quote (after Insert) {

    Set<Id> qid = new Set<Id>();
    decimal bqn=0,fqn =0;
    for(Quote q : trigger.new){
        System.debug('**** 0 q id : '+q.id);
         qId.add(q.opportunityid);    
    }
    
    List<Opportunity> o = [select id, Next_Budget_Quote_Number__c,
                 Next_Firm_Quote_Number__c 
                 from Opportunity where id =:qid];
    
    List<Quote> qu = [select id, recordtypeid from quote where id =: qid];
    
   
    id brecordtypeid = [select id,name from RecordType where sobjecttype='Quote' 
                        and name='Budget Quote'].id;
    id frecordtypeid = [select id,name from RecordType where sobjecttype='Quote' 
                        and name='Firm Quote'].id;

    id oid = System.currentpageReference().getParameters().get('oppid');
    String Typ = System.currentpageReference().getParameters().get('Type');
    String Rec = System.currentpageReference().getParameters().get('Rec');
    System.debug('o[0].Next_Budget_Quote_Number__c'+o[0].Next_Budget_Quote_Number__c);

     try
    {
         bqn = o[0].Next_Budget_Quote_Number__c + 1;
    }
    catch(NullPointerException ex)
    {
         bqn = 1;
    }
    try
    {
         fqn = o[0].Next_Firm_Quote_Number__c + 1;
    }
    catch(NullPointerException ex)
    {
         fqn = 1;
    }
    List<recordtype> brec = [select id from recordtype where name = 'Budget Quote'];
    List<recordtype> frec = [select id from recordtype where name = 'Firm Quote'];
    
   for(Opportunity op : o){
       
       If(Rec == 'Budget Quote' ){
                    o[0].Next_Budget_Quote_Number__c = bqn ;
                    } else
       If(Rec == 'Firm Quote' ){
                    o[0].Next_Budget_Quote_Number__c = fqn ;
                    }
               }
                    update o;
    }

 

For the visualforce page, I am passign values through the url, but don't need the values for the standard Opportunity object. How do I solve this problem?

Thank you

  • September 14, 2011
  • Like
  • 0

Hi All,

I have written a trigger on opportunity and inside the trigger i have called @future method of a class.I am unable to test my trigger.

 

trigger ConfirmationEmailContentTrigger on Opportunity (after insert,before update)
{

List<Opportunity> listOpp = new List<Opportunity>();
list<id> ids=new list<id>();
for (Opportunity op: trigger.new)
{
ids.add(op.id);
if(Trigger.isInsert)
{
Opportunity oppNew = [SELECT Id, StageName FROM Opportunity WHERE Id =:op.Id];
//oppNew.Confirmation_Email_Content__c = '';
system.debug('Opportunity Value'+op.AccountId);
if(op.AccountId != null)
{
Account acc = [SELECT Id FROM Account WHERE Id =:op.AccountId limit 1];
system.debug('Account Value'+acc);
if(acc != null)
{
Contact[] con = [SELECT Id, Email FROM Contact WHERE AccountId =:acc.id order by CreatedDate asc limit 1];
if (con.size() > 0)
{
//oppNew.Email__c = con[0].Email;
//oppNew.Notification_Email_Address__c = con[0].Email;
}
}
}
listOpp.add(oppNew);
if (listOpp != null && !listOpp .isEmpty())
{
Database.update(listOpp);
}
}
else if(op != null && Trigger.isUpdate)
{

if(op.StageName == 'Tickected')
{

string result='';

}

}

}
if(ids.size() > 0)
CallFromTriggerTest.updateContact(ids);
}

 

//////////////////////// Apex Class having @future    ////////////////////////////

public class CallFromTriggerTest
{
@future(callout=true)
public static void updateContact(list<id> usercontactid )
{
system.debug('@@@@@@@@@@@@@@@@@' +usercontactid );
string result='';
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('http://abc.com?id=');//+op.Id);
req.setMethod('GET');

HttpResponse res = h.send(req);
result = res.getBody();
}
static testmethod void coverClass()
{

Account a=new Account(name='test');
insert a;
List<id> listOpp = new List<id>();
Opportunity op=new Opportunity(name='testOpp',CloseDate=system.today(),StageName='Tickected',accountid=a.id);
insert op;
listOpp.add(op.id);
//CallFromTriggerTest c=new CallFromTriggerTest();
CallFromTriggerTest.updateContact(listOpp);
}
}

 

Please help me  for test the trigger.

 

Hi All,

Is there any standard functionality through which i can get the record name on which if some one has added any comment or have changes some thing???? Suppose i have an account name "Test" and on that account some other users has added a comment. So is there any was to get that account name i.e. "Test" inside the email send by salesforce????? Right now i am not geting the name of the Account with that email.

 

Thanks

Ashish Rai

Hi All,

Is there any standard functinality to use unsubscribe url inside the email template so that if some one who has unubscribe this option then that contact would not get any mass email in future??????

 

Thanks

Ashish Rai

Hi All,

        What is the basic difference between these two system.currentPagereference.getParameters().get() and Apexpages.currentpage().getparamethers().get()????????????

Hi All,

     Is there any way to get the index of picklist inside the validation rule????  I have a picklist having value a,b,c,d . So if i have selected c as picklist value next time when i update this record with picklist value as a,b it will through an error since this value is less in indexing(for example index of a is 1,b is 2 , c is 3 and d is 4). I can update the value of pickist which having greter than equal index value then existing.

Hi All,

I want three fields should be mendatory once the Stage(picklist) is declined. These three fields are of type Lookup,Text and Number.

Hi All,

Can any one please tell me what protocol is salesforce using for SFO and CFO integration with Outlook??????

Hi All,

I want to give the permisson  to Schedule Report to the user having license Salesforce Plateform. I am unable to find that option inside the profile having License as Salesforce Platform. Can any one help me how to enable this for the Standard Plateform Users????????

Hi All,

I need an urgent support on ParentgroupVal Function used in Reports (custom summary formula). I am expliaining the scenario below :

 

1) There are 3 columns in th report. - a, b, c showing individual numerical values ; Column d = Sum of column (a+ b) ; Column e= sum of column (a+b+c)

2) All these information is grouped Account wise (showing the sum under each grouping in column d & e)

3) Now we want to calculate the % Value for each of the values in column d & e out of the total value under each group.

 

Can we attain the objective using the Parent Group Val function in the Report (Custom Summary Formula). Please share the entire details of the formula to be created using ParentGroup Val functionality.

 

Below is my scenario:

So any one please suggest me how to show the value inside  % of formula1 by creating a formula with the help of parentgroupval.

 

 

AccountName(GroupBy this field)Amount2Amount3Formula1
(amount2+amount3)
% of formula1
Abc101525(25/40)*100 % i.e. 62.5
 10515(15/40)*100% i.e. 37.5
   GroupSum=40 



Hi All,

Can any one suggest me how to use Web to Object inside the developer org??? This feture is recently added by salesforce in spring 12 release. Please help me how to use this????

Hi All,

 

I have a customer portal user having license Customer Portal Manager Custom. So Portal User is able to see the Account and Contact but when i am tring to assign the task to the portal user i am geting an error that Portal User Can't owned an activity. If salesforce provide the assign user as Customer Portal then there must be way to Assign this to portla User??????? Can any one tell me that what i going to miss here??????

 

 

Hi All,

We have a link for other  whenever we see any object(Contact) view i.e. extrim right after Z sorting option. So when ever i click on this it always returns it always return no record to display. So can any one tell me wht is the criteria used of geting a record by clicking on other link???????????????????

Hi All,

I have a custom object and which having two master deatils relation ship with diffent object. So now when i go to OWD setting i found that for this object default setting is Controller by Parent. I want to know in this case it will conside which object as Parent?????????

Hi All,

     There is a field with name call type(picklist), call duration  on object Task. I have checked this is visible for Admin but is read only field. So even admin is not able to make changes in this field. Can any one tell me how to make these fields editable for Admin.

 

Thanks in Advance.

Hi All,

I want to add 3 months on my date type field.For example if Date=30/11/2012 then the formula field should display value as 01/03/2012. I am using this formula which is working fine for day value <= 28.

 

If(year(datefield__c) < 10, Date(year(datefield__c),month(datefield__c)+3,day(datefield__c)),

Date(year(datefield__c)-1,month(datefield__c)+3-12,day(datefield__c)))

 

The above formula give me the formula field value as error for the Datefield value=30/11/2011. I want value should be 01/03/2012. Please help me on this.

Hi All,

     I have founded that Deploy button(for managed package) is still enable inside the Non-OEM Org. When i have clicked on Managed License Its shows Allowed Licenses=2 and Used Licenses=2 but in detials it show only one user there. Can any one suggest me that what is the reason for not showing the all added user details?????? 

Hi all,     

        Please any one send me the exact code for httprequest with accesstoken to retrive one org date from anothe org. I am sing this but geting respone as Invalid Token (but i ma puting the correct access token). So tell me what i am doing wrong in below code:

 

httprequest hreq=new httprequest();//https://login.salesforce.com/id/00D90000000aSjoEAE/00590000000eb7cAAAhreq.Setendpoint('https://ap1.salesforce.com');hreq.setmethod('GET');hreq.setHeader('Authorization: OAuth ', '00D90000000aSjo!AQgAQNfbCS3aunHX37ko2VhwXzk4holpYFrU9juuCIMdanXC54DAjI916nYNvzZHjOV2vRubCiT1XZGeongMBAVxtdMfpLlN');//hreq.setHeader('Content-Type', 'text/xml;charset=UTF-8');hreq.setHeader('SOAPAction','');hreq.setHeader('Host','https://ap1.salesforce.com');http htp=new http();httpResponse res=htp.send(hreq);system.debug('%%%%%%%%%%%%%' +res);System.debug('@@@@@@@@' +res.getBody());

 Please help me on this.

 

 

Hi all,

      Please any one send me the exact code for httprequest with accesstoken to retrive one org date from anothe org. I am sing this but geting respone as  Bad_OAuth_Token. So tell me what i am doing wrong in below code:

 

httprequest hreq=new httprequest();

hreq.Setendpoint('https://login.salesforce.com/id/00D90000000aSjoEAE/00590000000eb7cAAA');

hreq.setmethod('GET');

hreq.setHeader('Authorization',':OAuth 00D90000000aSjo!AQgAQIRuHIv1pXGwo306PxvZCcgeDp_S__T1jWwarX9KNUzCQO74prs0xPfoE49S7GGHWUkubZlA.q_6N34TPj9036UaPNPt');


//hreq.setHeader('Host','https://ap1.salesforce.com');

http htp=new http();

httpResponse res=htp.send(hreq);
system.debug('%%%%%%%%%%%%%' +res);

Hi all,

   can any one help we the exact httpreqest with access token . I am using this but getiing a response "Bad_OAuth_Token" which comes when you are passing the wrong token.  

 

httprequest hreq=new httprequest();

hreq.Setendpoint('https://login.salesforce.com/id/00D90000000aSjoEAE/00590000000eb7cAAA');

hreq.setmethod('POST');

hreq.setHeader('Authorization: ','OAuth 00D90000000aSjo!AQgAQNfbCS3aunHX37ko2VhwXzk4holpYFrU9juuCIMdanXC54DAjI916nYNvzZHjOV2vRubCiT1XZGeongMBAVxtdMfpLlN');


hreq.setHeader('Host','https://ap1.salesforce.com');

http htp=new http();

httpResponse res=htp.send(hreq);system.debug('%%%%%%%%%%%%%' +res);

System.debug('@@@@@@@@' +res.getBody());

 

Can any one help me on this???????????????

Hi all,

      Is there any way to show chatter for customer portal user?????????????????

Hi All,

I have written a trigger on opportunity and inside the trigger i have called @future method of a class.I am unable to test my trigger.

 

trigger ConfirmationEmailContentTrigger on Opportunity (after insert,before update)
{

List<Opportunity> listOpp = new List<Opportunity>();
list<id> ids=new list<id>();
for (Opportunity op: trigger.new)
{
ids.add(op.id);
if(Trigger.isInsert)
{
Opportunity oppNew = [SELECT Id, StageName FROM Opportunity WHERE Id =:op.Id];
//oppNew.Confirmation_Email_Content__c = '';
system.debug('Opportunity Value'+op.AccountId);
if(op.AccountId != null)
{
Account acc = [SELECT Id FROM Account WHERE Id =:op.AccountId limit 1];
system.debug('Account Value'+acc);
if(acc != null)
{
Contact[] con = [SELECT Id, Email FROM Contact WHERE AccountId =:acc.id order by CreatedDate asc limit 1];
if (con.size() > 0)
{
//oppNew.Email__c = con[0].Email;
//oppNew.Notification_Email_Address__c = con[0].Email;
}
}
}
listOpp.add(oppNew);
if (listOpp != null && !listOpp .isEmpty())
{
Database.update(listOpp);
}
}
else if(op != null && Trigger.isUpdate)
{

if(op.StageName == 'Tickected')
{

string result='';

}

}

}
if(ids.size() > 0)
CallFromTriggerTest.updateContact(ids);
}

 

//////////////////////// Apex Class having @future    ////////////////////////////

public class CallFromTriggerTest
{
@future(callout=true)
public static void updateContact(list<id> usercontactid )
{
system.debug('@@@@@@@@@@@@@@@@@' +usercontactid );
string result='';
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('http://abc.com?id=');//+op.Id);
req.setMethod('GET');

HttpResponse res = h.send(req);
result = res.getBody();
}
static testmethod void coverClass()
{

Account a=new Account(name='test');
insert a;
List<id> listOpp = new List<id>();
Opportunity op=new Opportunity(name='testOpp',CloseDate=system.today(),StageName='Tickected',accountid=a.id);
insert op;
listOpp.add(op.id);
//CallFromTriggerTest c=new CallFromTriggerTest();
CallFromTriggerTest.updateContact(listOpp);
}
}

 

Please help me  for test the trigger.

 

Hi

 

I have a field on Agreement which is called ANNUAL RENT.

 

I want to create the same field on the Transaction object which is also ANNUAL RENT and I want the value from the Agreement object to get populated automatically in the Transaction object.

 

Can anyone please help me with this.

 

Thanks

 

Finney

  • April 02, 2012
  • Like
  • 0

Hi All,

     Is there any way to get the index of picklist inside the validation rule????  I have a picklist having value a,b,c,d . So if i have selected c as picklist value next time when i update this record with picklist value as a,b it will through an error since this value is less in indexing(for example index of a is 1,b is 2 , c is 3 and d is 4). I can update the value of pickist which having greter than equal index value then existing.

Hi,

 

I am a new user to Apex.

 

I am trying to write a trigger which will automatically enter the case open date to a custom date field on my Account object when anyone in my group opens a case for the client.

 

I understand the difficulty is to sync records between two objects. In both objects, I have a field called Account Name. My guess is to figure out a way to match this field in both objects and then write down a code to insert the case open date to the custom field.

 

I also copied and tried to modify the code from other users to fit my own situation, however I may get into a wrong direction. Following is the code I copied, I put it in the case object:

 

trigger Caseupdate on Case(after insert) {
Case b = new Case();
Set<Date> AccountIDs = new set<Date>();
map<Date, Account> AcctMap = new Map<Date, Account>();
for(Account c : Trigger.new){
AccountIDs.add(c.CreatedDate);
}
for(Account at:[Select a.CreatedDate
From Account a where a.CreatedDate = 'Date/Time Opened']){
AcctMap.put(at.CreatedDate, at);
}
for(Account c: Trigger.new){
if(AcctMap.contains(c.CreatedDate)){
c.Last_Update = AcctMap.get(c.CreatedDate);
}
}
}

 

Thanks in advance, any helps are much appreciated.

Hi,

 

 

I have 2 formulas, each of them tells to the logged user if their are selected in a custom look up : Lookuptouser/Lookuptouser2:

 

 

1: IF( Lookuptouser__r.Id  = $User.Id, "Yes", "No")

2: IF ( Lookuptouser2__r.Id = $User.Id, "Yes", "No")

 

 

How can I put these two formulas in one.

 

So instead of checking individually, I want to check if I am in Lookuptouser OR Lookuptouser2, with a Yes or NO as the answer

  • February 10, 2012
  • Like
  • 0

HI , 

I have to generate a report where in the bars have to dispalyed 

according to the data from the controller, Could anyone help me

How could i achieve this...

I am developing a simple app to help our sales reps manage orders of product samples sent to customers.  I am currently writing a trigger on the insert event of a custom object called Sample Order.  The code is below; as you will see, I'm getting errors on two lines - the line where I set the Task.WhatId and Task.OwnerId.  Can someone help me with this, please?  I'm very new to Salesforce.com and Apex code.  Thanks!

 

trigger CreateOrderTask on Sample_Order__c (after insert) {
    Task orderTask = new Task();
    orderTask.ActivityDate = date.today() + 7;


    // ERROR for line below is "Illegal assignment from Schema.SObjectField to Id"
    orderTask.WhatId = Sample_Order__c.id;


    // ERROR for line below is "Illegal assignment from Schema.SObjectField to Id
    // Sales_Rep__c is a reference field to User object
    orderTask.OwnerId = Sample_Order__c.Sales_Rep__c.Id;


    orderTask.Priority = 'High';
    orderTask.Status = 'Not Started';
    orderTask.Subject = 'Sample Order Request for ' + Sample_Order__c.Account__c.Name;
    orderTask.IsReminderSet = true;
    orderTask.ReminderDateTime = datetime.now() + 7;
    Insert orderTask;
}

  • October 11, 2011
  • Like
  • 0

Hello,

I want to change to Change the format of a CreatedDate.

Now when i put it on a VF it looks like this:

Sat Oct 08 11:07:45 GMT 2011

 

I used valueofGmt, format, and that stuff but nothing worked for me to convert it to this format:

DD.MM.YYYY

 

Thank you in advance.

Hi,

 I have a class that enters values(from a lookup) in AccountTeamMember object from a custom visualForce page.There are 3 main parametres that are supposed to be entered

1.AccountName(Look up)

2.UserName(Look up)

3.TeamMemberRole(dropdown)

The method is given below:

 public void save(){
   try
    {      
       if (accTeamMem == null)  
                      {      
                        accTeamMem = new AccountTeamMember(); 
                       } 
      String accountID =  ApexPages.currentPage().getParameters().get('searchAccount');
      String UserID  =  ApexPages.currentPage().getParameters().get('searchName');  
      String teamMemberRole = ApexPages.currentPage().getParameters().get('searchRole');     
      system.debug('accountid ='+accountID );
     system.debug('accountid ='+UserID );
     // system.debug('accountid ='+teamMemberRole );      
      insert accTeamMem;   
    }
     Catch (DMLException e) { 
       ApexPages.addMessages(e);      
        }   
          
        //return null;
     LoadData();
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Your entry has been added')); 

        }        
Custom controller used:  TeamMemberAssignmentController 

I wanna write a test class for this method, so far this is what i've done:

 

 

@isTest
private class TestTeamMemberAssignmentController    {

static testMethod void runTest() {
User u = [Select id,name from User where id = :UserInfo.getUserID()];
        ApexPages.currentPage().getParameters().put('searc​hAccount','a2');
        ApexPages.currentPage().getParameters().put('searc​hName','u.id');
        ApexPages.currentPage().getParameters().put('searc​hRole','Account Manager');
        
        TeamMemberAssignmentController c = new TeamMemberAssignmentController();
        
        c.save(); 
}
}

This is showing "insert failed" error u.id and a2 are not getting inserted.Please help me,this is my first test class!!!!

Thanks

 

Hi,

 

trigger contactEndDate on Contract (after insert, after update) {
    Contract contract = trigger.new[0];
    list<Contact> contactList = new list<Contact>();
    Date sDate = contract.EndDate;
    Id accID = contract.AccountId;
    if(accID != null) {
        Contact[] con = [select SMA_End_Date__c,Name From Contact where AccountId = :accID];
        if(con != null && con.size() > 0) {
            for (Contact contact : con) {
                contact.SMA_End_Date__c = sDate;
                contactList.add(contact);               
            }
            update contactList;      
        }
    }
}

 

When i try to invoke the above trigger i am getting this error

 

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger contactEndDate caused an unexpected exception, contact your administrator: contactEndDate: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 003L0000002xSxCIAU; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, ContactObj: []: Trigger.contactEndDate: line 13, column 13

 

Can anyone please help me to resolve this problem?

 

Thanks and Regards

Hari G S

 

Hi ,

 

 I have created a Xml string type and passed it to a Apex call out method. The result of this method is a string too. Now i would want to convert the Result Xml string into a List object. please suggest.

 

public class APImageUpdates {
  public void APFilesMissing()
    {
      // Create list for Available Aupairs
      List<Contact> APContacts = [Select Id,AP_Status__c,RecordTypeId from Contact where AP_Status__c ='Available' AND contact.RecordTypeId ='012300000000AHhAAM' ];
      
      // Root of the Xml list
      string XmlString = '<APFilesData>';      
      for(Contact contact: APContacts) 
      {            
        for(AP_Application__c APAppObj: [Select Id,Au_Pair__c,AP_Folder_Name__c,Photo1__c,Photo2__c,Photo3__c,Photo4__c From AP_Application__c where Au_Pair__c =: contact.Id])
        {        
          if(APAppObj.IsExist_Photo1__c == false) 
          {  
            XmlString += '<APFiles>';
            XmlString += '<Apfoldername>';
            XmlString += APAppObj.AP_Folder_Name__c;
            XmlString += '</Apfoldername>';
            XmlString += '<Id>';
            XmlString += APAppObj.Id;
            XmlString += '</Id>';
            XmlString += '<APID>';
            XmlString += APAppObj.Au_Pair__c;
            XmlString += '</APID>';
            XmlString += '<FileUrl>';
            XmlString += APAppObj.Photo1__c;
            XmlString += '</FileUrl>';
            XmlString += '</APFiles>';    
                                     
          }
          
          if(APAppObj.IsExist_Photo2__c == false )
          {
            XmlString += '<APFiles>';
            XmlString += '<Apfoldername>';
            XmlString += APAppObj.AP_Folder_Name__c;
            XmlString += '</Apfoldername>';
            XmlString += '<Id>';
            XmlString += APAppObj.Id;
            XmlString += '</Id>';
            XmlString += '<APID>';
            XmlString += APAppObj.Au_Pair__c;
            XmlString += '</APID>';
            XmlString += '<FileUrl>';
            XmlString += APAppObj.Photo2__c;
            XmlString += '</FileUrl>';
            XmlString += '</APFiles>';  
          }
          
          if(APAppObj.IsExist_Photo3__c == false )
          {
            XmlString += '<APFiles>';
            XmlString += '<Apfoldername>';
            XmlString += APAppObj.AP_Folder_Name__c;
            XmlString += '</Apfoldername>';
            XmlString += '<Id>';
            XmlString += APAppObj.Id;
            XmlString += '</Id>';
            XmlString += '<APID>';
            XmlString += APAppObj.Au_Pair__c;
            XmlString += '</APID>';
            XmlString += '<FileUrl>';
            XmlString += APAppObj.Photo3__c;
            XmlString += '</FileUrl>';
            XmlString += '</APFiles>';  
          }
          
          if(APAppObj.IsExist_Photo4__c == false )
          {
            XmlString += '<APFiles>';
            XmlString += '<Apfoldername>';
            XmlString += APAppObj.AP_Folder_Name__c;
            XmlString += '</Apfoldername>';
            XmlString += '<Id>';
            XmlString += APAppObj.Id;
            XmlString += '</Id>';
            XmlString += '<APID>';
            XmlString += APAppObj.Au_Pair__c;
            XmlString += '</APID>';
            XmlString += '<FileUrl>';
            XmlString += APAppObj.Photo4__c;
            XmlString += '</FileUrl>';
            XmlString += '</APFiles>';  
          }
          
        }
      }
      
      //Close root Xml
      XmlString += '</APFilesData>';
      ServiceMethod(XmlString);
      }
   
   //Service Method  
   public static void ServiceMethod(string xml)
   {
     string ServiceResult = '';
     WebServiceOrg.AjaxSoap Service = new WebServiceOrg.AjaxSoap();
      ServiceResult = Service.GAPNetworkImages(xml);  
      Checkboxupdate(ServiceResult);   
   }
 
   public static void Checkboxupdate(string xml) 
   {

 List<AP_Application__c> APAppObj = new List<AP_Application__c>();
   }

 

 

I need to convert the resulting Xml and populate the results to List<AP_Application__c>. can someone please suggest

 

Thank you.
  

Hi,

 

Have doubt on invoking external web services using apex.

 

1. First we will generate apex class from the wsdl of external application.

 

But after that how we will proceed with that??

 

kindly let me know the process.

 

If you have any doc regarding this do share it with me.

 

Thanks in advance,

MVP

  • October 07, 2011
  • Like
  • 0

 

Hi,

 

While tring to deploy the code to production i am getting this error 

 

System.LimitException: Too many SOQL Queries:101

 

Why this error is occuring?

 

My code is

 

trigger productTrigger on Product2 (after insert, after update) {
    Product2 myProd = Trigger.new[0];    
    Purchased_Products_del__c[] puchasedProd = [select Id, Product_Code__c from Purchased_Products_del__c where Product__c=:myProd.Id];
    if(puchasedProd != null && puchasedProd.size() > 0) {        
        for(Purchased_Products_del__c pProd:puchasedProd) {
            if(pProd.Product_Code__c != myProd.ProductCode) {
                pProd.Product_Code__c = myProd.ProductCode;
                update pProd;
            }
        }
    }
} 

 

Thanks and Regards

Hari G S

Hi,

I am trying to get the following output in my code. I already have my instance url and access_token. In the documentation for Oauth2, it tells me to send a get request to the id url followed by an OAuth authorization HTTP header containing the access token. Can someone please give me a sample code on how can I send a get request to the id url? I am trying to get the url for the api endpoint. 

{
	"id":"https://login.salesforce.com/id/00D50000000IZ3ZEAW/00550000001fg5OAAQ",
	"asserted_user":true,
	"user_id":"00550000001fg5OAAQ",
	"organization_id":"00D50000000IZ3ZEAW",
	"username":"user@example.com",
	"nick_name":"user1.2950476911907334E12",
	"display_name":"Sample User",
	"email":"user@example.com",
	"status":{
		"created_date":"2010-11-08T20:55:33.000+0000",
		"body":"Working on OAuth 2.0 article"
	},
	"photos":{
		"picture":"https://c.na1.content.force.com/profilephoto/005/F",
		"thumbnail":"https://c.na1.content.force.com/profilephoto/005/T"
	},
	"urls":{
		"enterprise":"https://na1.salesforce.com/services/Soap/c/{version}/00D50000000IZ3Z",
		"metadata":"https://na1.salesforce.com/services/Soap/m/{version}/00D50000000IZ3Z",
		"partner":"https://na1.salesforce.com/services/Soap/u/{version}/00D50000000IZ3Z",
		"rest":"https://na1.salesforce.com/services/data/v{version}/",
		"sobjects":"https://na1.salesforce.com/services/data/v{version}/sobjects/",
		"search":"https://na1.salesforce.com/services/data/v{version}/search/",
		"query":"https://na1.salesforce.com/services/data/v{version}/query/",
		"recent":"https://na1.salesforce.com/services/data/v{version}/recent/",
		"profile":"https://na1.salesforce.com/00550000001fg5OAAQ"
	},
	"active":true,
	"user_type":"STANDARD",
	"language":"en_US",
	"locale":"en_US",
	"utcOffset":-28800000,
	"last_modified_date":"2011-01-14T23:28:01.000+0000"
}

 I used curl to do the request, but I can not seem to find out why it does not return anything. $url is my  id url and $access_token is my token.  The returning status is always 302 instead of 200. Please I need help on figuring why this is happening. I've red the oauth documentations so many times, but I still can not figure what is wrong. Please I would appreciate it if someone had a look at my code.

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER,
            array("Authorization: OAuth $access_token"));
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

if ( $status != 200 ) {
        die("Error: call to URL $url failed with status $status, response $json_response, curl_error " .     curl_error($curl) . ", curl_errno " . curl_errno($curl));
    }

 

  • September 12, 2011
  • Like
  • 0

Hi,

We are calling chatter REST APIs from our site. We are using oauth for authentication purpose. We are working in .NET platform (C sharp). Till last 3 days all gone in right manner. We were getting data from chatter and we were able to post also. We tried posting comment, files, like and unlike. All well.

 

But from last 3-4 days we are getting 403 Forbidden error intermittently. Not getting exactly what is the issue.

While doing work around for this we got some pointers like REST API call limitation per 24 hours

http://www.salesforce.com/us/developer/docs/api/Content/implementation_considerations.htm  but creating new org will also dont help, gives same error.

 

Some Technical details -

The salesforce environment I am using - https://ap1.salesforce.com/

Authorize url - https://login.salesforce.com/services/oauth2/authorize

Access token url - https://login.salesforce.com/services/oauth2/token

 

we get access token and refresh token but when we tries to call any simple API like users/me/groups or chatter/users/me, we get 403.

 

Can any one help us out in where we are going wrong? Is it our coding issue or server down time issue.? If it is coding issue then why it is working intermittently?

 

Thanks,

Sarvesh.