• Shahab Khan
  • NEWBIE
  • 60 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 22
    Questions
  • 43
    Replies
Hi,

On add new user page i am not able to select salesforce option in user license there are only two options
Chatter Free and Chatter External due to which i am not able to select my custum created new profile.

User-added image

Can some body help me how i can select salesforce license?

Thanks,
Shahab
Hello,

I have a scheduled class of managed package which insert paymnets i have added trigger after insert of payment and i want to add opportunity and opportunity contact role.
This works fine in Sandbox but in live i am getting following error and due to that error my opportunities not added.

"Future method cannot be called from a future or batch method: npo02.OpportunityRollups.rollupContactsandHouseholdsForTrigger(Set<Id>)"

Here is my scheduled apex class.
 
/*** ScheduleRebillingCycle: ***/ 

public with sharing class ScheduleRebillingCycle implements Schedulable{

    List<Rebilling_Cycle__c> rebillingCycles = new List<Rebilling_Cycle__c>();
    List<List<Rebilling_Cycle__c>> cycleList = new List<List<Rebilling_Cycle__c>>(); 
    List<Rebilling_Cycle__c> cycleTest = new List<Rebilling_Cycle__c>();
    List<String> transactionIDs = new List<String>();
    Boolean isFromBatchFile = false;
    
    public ScheduleRebillingCycle(List<Rebilling_Cycle__c> cycles, Boolean isBatchFile){
        if (cycles != null)
            cycleTest = cycles;
        isFromBatchFile = isBatchFile;
    }
     public ScheduleRebillingCycle(){
    } 
    /* Executes the rebilling cycle that has been set up inside of SalesForce. If approved, create a Payment record.
    //
    */
    public void execute(SchedulableContext ctx) {
         if (cycleTest.IsEmpty()) {
            try {
              rebillingCycles = [SELECT Id, Name, Account_Name__c, Contact_Name__c, Transaction_ID__c, Account_Type__c, 
                  Routing_Number__c, Rebill_Next_Date__c,Rebill_Frequency__c, Rebill_Frequency_Number__c, Payment_Type__c, 
                  Card_Number__c, Expiration_Month__c, Expiration_Year__c, Account_Number__c, Rebill_Cycles_Remaining__c,
                  Rebill_Status__c, Rebill_Amount__c, Campaign_Name__c FROM 
                  Rebilling_Cycle__c WHERE Rebill_Next_Date__c = TODAY AND (Rebill_Cycles_Remaining__c = 'Infinite' OR  
                  Rebill_Cycles_Remaining__c != '0') AND Rebill_Status__c = 'Active'];
            } catch(Exception e){System.debug('ERROR' + e);}
      
            for(Rebilling_Cycle__c c: rebillingCycles){ 
                cycleTest.add(c);
            }
        }
              if ([SELECT count() FROM AsyncApexJob WHERE JobType='BatchApex' AND (Status = 'Processing' OR 
                  Status = 'Preparing' OR Status = 'Holding' OR Status = 'Queued')] < 5){
                  BatchRebillingCycles cycle = new BatchRebillingCycles(cycleTest, isFromBatchFile);
                  ID batchprocessid = Database.executeBatch(cycle);
              } else {
                  ScheduleRebillingCycle sch = new ScheduleRebillingCycle(cycleTest, isFromBatchFile);
                  Datetime dt = Datetime.now().addMinutes(2);
                  String timeForScheduler = dt.format('s m H d M \'?\' yyyy');
                  Id schedId = System.Schedule('BluePayRetry'+timeForScheduler,timeForScheduler,sch);   
              }
              cycleTest.clear();
              
    }   
    
}

And here is my trigger code.
 
trigger BpRCTrigger on BluePay_DNA__Payment__c (after insert)
{
	try
    {
        List < Opportunity > oppList = new List<Opportunity>();
        List < String > contact_ids = new List<String>();
        List < OpportunityContactRole > roleList = new List<OpportunityContactRole>();
        oppList.clear();
        roleList.clear();
        Opportunity opportunity = new Opportunity();
        OpportunityContactRole role = new OpportunityContactRole();
        Contact prev_contact_rec;
        Account prev_account_rec;
        Datetime cDT = System.now();
        String current_date = cDT.format('MM/d/yyyy');
        Date re_today_date = Date.today();
        
        
        for (BluePay_DNA__Payment__c bpp : trigger.new)
        {
            if(bpp.BluePay_DNA__Is_Recurring__c == 'Yes' && bpp.BluePay_DNA__Transaction_Result__c == 'APPROVED')
            {
                String contact_id = String.valueOf(bpp.BluePay_DNA__Contact_Name__c);
                String campaign_id = String.valueOf(bpp.BluePay_DNA__Campaign_Name__c);
                String rebilling_cycle_id = String.valueOf(bpp.BluePay_DNA__Rebilling_Cycle_Reference_ID__c);
                
                if(contact_id != null && contact_id != '' && campaign_id != null && campaign_id !='')
                {
                    System.debug('test: 1');
                    prev_contact_rec = null;
                    prev_account_rec = null;
                    prev_contact_rec = [select AccountId, Donation_Type__c, Other_Gift_Type__c from Contact where Id=:contact_id limit 1];
                    prev_account_rec = [select Name from Account where id=:prev_contact_rec.AccountId limit 1];
                    opportunity = null;
                    role = null;
                    opportunity = new Opportunity();
                    role = new OpportunityContactRole();
                    
                    System.debug('test: 2');
                    opportunity.accountId = prev_contact_rec.AccountId;
                    opportunity.name = prev_account_rec.Name + ' $' + bpp.BluePay_DNA__Amount__c + ' Recurring Donation ' + current_date;
                    opportunity.Donation_Type__c = prev_contact_rec.Donation_Type__c;
                    opportunity.BluePay_DNA__Donation_Type__c = (prev_contact_rec.Donation_Type__c != null) ? prev_contact_rec.Donation_Type__c : '';
                    opportunity.Other_Donation_Type__c = prev_contact_rec.Other_Gift_Type__c;
                    opportunity.Donation_Source_Type__c = 'Via Website';
                    opportunity.CampaignId = campaign_id;
                    opportunity.amount = Double.valueof(bpp.BluePay_DNA__Amount__c);
                    opportunity.CloseDate = re_today_date;
                    opportunity.stageName = 'Posted';
                    
                    if(rebilling_cycle_id != null && rebilling_cycle_id !='')
                    {
                        BluePay_DNA__Rebilling_Cycle__c reb_cycle = [select BluePay_DNA__Recurring_Donation_ID__c from BluePay_DNA__Rebilling_Cycle__c where Id=:rebilling_cycle_id limit 1];
                        if(reb_cycle.BluePay_DNA__Recurring_Donation_ID__c != null && reb_cycle.BluePay_DNA__Recurring_Donation_ID__c !='')
                        {
                            opportunity.npe03__Recurring_Donation__c = reb_cycle.BluePay_DNA__Recurring_Donation_ID__c;
                        }
                    }
                    
                    oppList.add(opportunity);
                    contact_ids.add(contact_id);
                    System.debug('test: 4');
                }
                    
            }
        }
        if (oppList != null && oppList.size() > 0)
        {
            insert(oppList);
            Integer count = 0;
            for(Opportunity opp: oppList)
            {
                role = null;
                role = new OpportunityContactRole();
                role.contactId = contact_ids[count];
                role.Role = '10';
                role.opportunityId = opp.id;
                roleList.add(role);
                count++;
            }
            insert(roleList);
        }
    }
    catch (exception ex)
    {
        System.debug('Error occurd: ' + ex);
    }
}

Can some body help me how to fix that error so that trigger works fine.

Thanks,
Faraz
Hello,

I have write trigger on Contact before insert and before update for avoiding duplicate entry of Email.

Here is my code
trigger DuplicateEmail on Contact (before insert, before update)
{
	Contact val_con = trigger.new[0];
    Contact prev_contact_rec = null;
    if(val_con.Email != null && val_con.Email != '')
    {
        try
        {
            if (trigger.isInsert)
            {
                prev_contact_rec = [select Email from Contact where Email=:val_con.Email limit 1];
                system.debug('----->>> Email Before Insert New: ' + val_con.Email);
            }
            else if (trigger.isUpdate)
            {
                prev_contact_rec = [select Email from Contact where Email=:val_con.Email and Id !=:val_con.Id limit 1];
                system.debug('----->>> Email Before Update New: ' + val_con.Email);
                system.debug('----->>> Id Before Update New: ' + val_con.Id);
            }
            
            if(prev_contact_rec.Email != null && prev_contact_rec.Email != '')
            {
                Trigger.new[0].adderror('Email you provided has already exists');
            }
        }
        catch (exception ex)
        {
            System.debug('Error occurd: ' + ex);
        }
        
    }
}

It is working fine when inserting new contact. But when i update the email address of existing contact then the trigger gets old value of email field instead of new value for example old value of email was "foo@yahoo.com" i have updated it to "foo123@yahoo.com" instead of assigning "foo123@yahoo.com" value to val_con object it assigns "foo@yahoo.com" to it in case of before update trigger event.
Can some body help me how to fix it.

Thanks,
Shahab
i have custom controller with following signature

public with sharing class ScheduleRebillingCycle implements Schedulable


But when i try to instantiate it in other controller like below
ScheduleRebillingCycle ss = new ScheduleRebillingCycle();

It give me error "Invalid type: ScheduleRebillingCycle"

Please somebody help me how i can fix it.

Thanks,
Shahab
 
Hello Every One,

I am adding oppertunities of a contact programatically with stage name posted.
But under contact detail page the donation information is not updating.

User-added image

User-added image

Can anyone help me how to make it work?

Thanks,
Shahab
Hi,

Can some one help me how to display radio button with image as shown below.

User-added image

Thanks in advance.
Hi,

I have a number field (Number, 0) but when i put valuee 10000 in it it will diplay it as 10,000 i want to display it without comma.
I have selected number field because i need to select Max number from it and add 1 in Max number for new entry.
Can any body help me how i can do it.

Thanks,
Faraz
Hi,

My Change set is not able to deploy to production even have 85% overall code coverage in sandbox as shown below
User-added image
But in production it show 73% code coverage.
User-added image
Can any body help me how to fix this problem

Thanks in advance.