• himanshu323
  • NEWBIE
  • 30 Points
  • Member since 2012

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 6
    Replies
Hello,

I've created the trigger below on my OpportunityLineItem object.  There is a custom field on the Opportunity object called Max_Deliv_Hx__c which captures the highest number of Opportunity Products that have been included on an Opportunity.  I am trying to assign a value to each OpportunityLineItem from 1 to Max_Deliv_Hx__c, but only if that OpportunityLineItem does not already have a value.  When I run this trigger I get and error:

Error: Invalid Data.
Apex trigger UniqueDelivID caused an unexpected exception, contact your administrator: UniqueDelivID: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 00kn00000032bk8AAA; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 00kn00000032bk8) is currently in trigger UniqueDelivID, therefore it cannot recursively update itself: []: Trigger.UniqueDelivID: line 18, column 1


Can anyone provide some help?  Thanks.


trigger UniqueDelivID on OpportunityLineItem (before insert, before update) {

    //get the Product Numbers and other fields from the OpportunityLineItem and build a list of OpportunityLineItems to update

    List<OpportunityLineItem> oliList = new List<OpportunityLineItem>();

        for(OpportunityLineItem oli : [SELECT Id, Opportunity.Max_Deliv_Hx__c, Max_Deliv__c
                                       FROM OpportunityLineItem
                                       WHERE Id in : trigger.new]) {

        IF(oli.Max_Deliv__c = null){
            oli.Max_Deliv__c = oli.Opportunity.Max_Deliv_Hx__c + 1; //Update the OpportunityLineItem
        }
        oliList.add(oli);

    }

    update oliList; //Update the OpportunityLineItems with the Max_Deliv__c field

}
  • June 05, 2014
  • Like
  • 0

Hi EveryOne ,

I am facing an Issue in Wrapper Class in Sites . When I pass my wrapper class instance in the Login method then it is returning null.I have used my wrapper donationList list in many methods it is having value in those methods . I have also used getParameters and putParameters of ApexPages but it will only show me the 1st row record in my wrapper List.I want to insert many records based on my wrapper class values when the User is directed to the Customer Portal after logging in.Please help me with this Problem , I need to get my whole Wrapper List  values in Login method. In short I want to pass the List<Donation> value from one method to another when View state is null .

 

 

public with sharing class CustomUserSiteRegister

{

public PageReference goToSiteLoginPage()

    {

        PageReference pageRef = new PageReference('/apex/SiteLogin');

        pageRef.setRedirect(false);

      

        system.debug('this is DonationList111111111'+donationList);

        pageRef.getParameters().put('totalAmount123',string.valueOf(totalAmount));

           

for(Donation donPassParam : donationList)

{

                 

putAmountParam = string.valueOf(donPassParam.wFundAllocation.Amount__c);

putDonationTypeParam = donPassParam.wFundAllocation.Donation_Type__c;

putFundParam   = donPassParam.wFundAllocation.Fund__c;

putProgrammeParam     = donPassParam.wFundAllocation.Programme__c;

                                       

                  

}

     

return pageRef;

 }

 

public PageReference login()

     {       

PageReference pr= Site.login(username, password, '/apex/LoginPayment');

pr.setRedirect(false);

system.debug(‘this is donationList’+ donationList);

return pr;

}

 

List< Donation > donationList = new List< Donation >();

public class Donation

    {

        public Fund_Allocation__c wFundAllocation{get;set;} 

        public Boolean wIsSelected{get;set;}     

      

        public Donation( Fund_Allocation__c fundAllocation ,Boolean IsSelected)

        {           

            wFundAllocation=fundAllocation;

            wIsSelected   = IsSelected;           

        }

    }

}

Hi,

 

In the belowcode I am not getting how to input the RoleId of the User for which I am creating Person Account . In our customer Portal we have assigned Default role of user to Empty. But the above future call is throwing an error that 'Account Owner should have some role' and when I am passing some role to this 'UserRoleId' field it throwing again an error '

High Volume Portal Users cannot have a user role' can any one suggest what should I pass as UserRoleId in order to make my Future call working and the user can be cretesd with its personal account.

'

 

public with sharing class CustomUserSiteRegister{

public string fNAme{get; set;}
public String lastName{get; set;}
public String email{get; set;}
public String confirmEmail{get; set;}
public string country{get; set;}
public string state{get; set;}
public string city{get; set;}

public String communityNickname{get; set;}

public pagereference makeUserPersonAcc(){

recordType recType1 = [SELECT Name, SobjectType,IsPersonType FROM RecordType WHERE SobjectType='Account' AND developername = 'Person_Account' AND IsPersonType = true ];

Account personAcc= new Account();
personAcc.recordtype = recType1 ;
personAcc.firstName = fName;
personAcc.lastName = lastName;
personAcc.PersonEmail= email;
personAcc.BillingCountry = country;
personAcc.BillingState = state;
personAcc.BillingCity = city;

insert personAcc;
system.debug('this is peronAcc'+personAcc);

UserRole usrRole = [Select PortalAccountOwnerId,Name, PortalAccountId From UserRole limit 1];
system.debug('thi is usrRole'+ usrRole);

Profile p = [select id ,Name from profile where UserLicense.Name like '%Authenticated Website%' limit 1];
Profile p1 = [select id ,Name from profile where Name = 'Authenticated User'];

system.debug('this is profileName'+p1.Name);
Account getCon = [select id , PersonContactId from account where id =: personAcc.id];
system.debug('this is getCon'+personAcc.PersonContactId );

createUser(getCon.PersonContactId , personAcc.PersonEmail, personAcc.firstName, personAcc.lastName, Email ,(string)p1.id );

return null;}

// Setup nonSetup objects problem , so used @future.
@future static void createUser(id con, String email, String firstName, String lastName, String userName, String profileId ) {
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.EmailHeader.triggerUserEmail = true;
system.Debug('I am here'+con);
system.Debug('I am here');
system.Debug('I am here'+email);
User u = new User(alias = 'standt', email=email,
emailencodingkey='UTF-8', lastname=lastname, languagelocalekey='en_US',
localesidkey='en_US', profileid = profileId, contactId=con,
timezonesidkey='America/Los_Angeles', username=username , UserRoleId = '');

u.setOptions(dmo);
insert u;
}

 

 

 

Hi All,

I have different communities. How to apply relative URL in a single component to logout from the communities ?
when i logout from the particular community, it should redirect to their own login page.
Is there any possible way to implement this. I doubtfull, is relative URL could achieve this ? 
 
Hello,

I've created the trigger below on my OpportunityLineItem object.  There is a custom field on the Opportunity object called Max_Deliv_Hx__c which captures the highest number of Opportunity Products that have been included on an Opportunity.  I am trying to assign a value to each OpportunityLineItem from 1 to Max_Deliv_Hx__c, but only if that OpportunityLineItem does not already have a value.  When I run this trigger I get and error:

Error: Invalid Data.
Apex trigger UniqueDelivID caused an unexpected exception, contact your administrator: UniqueDelivID: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 00kn00000032bk8AAA; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 00kn00000032bk8) is currently in trigger UniqueDelivID, therefore it cannot recursively update itself: []: Trigger.UniqueDelivID: line 18, column 1


Can anyone provide some help?  Thanks.


trigger UniqueDelivID on OpportunityLineItem (before insert, before update) {

    //get the Product Numbers and other fields from the OpportunityLineItem and build a list of OpportunityLineItems to update

    List<OpportunityLineItem> oliList = new List<OpportunityLineItem>();

        for(OpportunityLineItem oli : [SELECT Id, Opportunity.Max_Deliv_Hx__c, Max_Deliv__c
                                       FROM OpportunityLineItem
                                       WHERE Id in : trigger.new]) {

        IF(oli.Max_Deliv__c = null){
            oli.Max_Deliv__c = oli.Opportunity.Max_Deliv_Hx__c + 1; //Update the OpportunityLineItem
        }
        oliList.add(oli);

    }

    update oliList; //Update the OpportunityLineItems with the Max_Deliv__c field

}
  • June 05, 2014
  • Like
  • 0

Hi EveryOne ,

I am facing an Issue in Wrapper Class in Sites . When I pass my wrapper class instance in the Login method then it is returning null.I have used my wrapper donationList list in many methods it is having value in those methods . I have also used getParameters and putParameters of ApexPages but it will only show me the 1st row record in my wrapper List.I want to insert many records based on my wrapper class values when the User is directed to the Customer Portal after logging in.Please help me with this Problem , I need to get my whole Wrapper List  values in Login method. In short I want to pass the List<Donation> value from one method to another when View state is null .

 

 

public with sharing class CustomUserSiteRegister

{

public PageReference goToSiteLoginPage()

    {

        PageReference pageRef = new PageReference('/apex/SiteLogin');

        pageRef.setRedirect(false);

      

        system.debug('this is DonationList111111111'+donationList);

        pageRef.getParameters().put('totalAmount123',string.valueOf(totalAmount));

           

for(Donation donPassParam : donationList)

{

                 

putAmountParam = string.valueOf(donPassParam.wFundAllocation.Amount__c);

putDonationTypeParam = donPassParam.wFundAllocation.Donation_Type__c;

putFundParam   = donPassParam.wFundAllocation.Fund__c;

putProgrammeParam     = donPassParam.wFundAllocation.Programme__c;

                                       

                  

}

     

return pageRef;

 }

 

public PageReference login()

     {       

PageReference pr= Site.login(username, password, '/apex/LoginPayment');

pr.setRedirect(false);

system.debug(‘this is donationList’+ donationList);

return pr;

}

 

List< Donation > donationList = new List< Donation >();

public class Donation

    {

        public Fund_Allocation__c wFundAllocation{get;set;} 

        public Boolean wIsSelected{get;set;}     

      

        public Donation( Fund_Allocation__c fundAllocation ,Boolean IsSelected)

        {           

            wFundAllocation=fundAllocation;

            wIsSelected   = IsSelected;           

        }

    }

}