• Nihar Sharma
  • NEWBIE
  • 89 Points
  • Member since 2015
  • Technical Analyst
  • Softweb Solutions

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 19
    Questions
  • 50
    Replies
I have built following apex trigger code and isAfter code is not executing because I have used recursive method in this trigger.

Please have a look into this and let me know what i have did wrong in this code :
 
trigger CreateOrderForOpportunity on Opportunity (before insert, after insert, after update) {
    
    if(trigger.isInsert){
        
        Map<ID,Schema.RecordTypeInfo> rt_Map = Opportunity.sObjectType.getDescribe().getRecordTypeInfosById();
        List<SBQQ__Quote__c> quotelist = new List<SBQQ__Quote__c>();
        List<SBQQ__QuoteLine__c> quoteLineList = new  List<SBQQ__QuoteLine__c>();
        List<SBQQ__QuoteLine__c> quoteLineDataServiceList = new  List<SBQQ__QuoteLine__c>();
        
        for(Opportunity opp : trigger.New){
            
            if(rt_map.get(opp.recordTypeID).getName().contains('CONECTIVIDAD') && opp.Coming_from_Portal__c == True){
                
                if(trigger.isBefore){
                    if(opp.Owner_Email_Address_coming_from_portal__c != Null){
                        List<user> uList = [select Id, Email from user where Email =: opp.Owner_Email_Address_coming_from_portal__c Limit 1];
                        if(uList.size() > 0)
                            for(User u : uList){
                                opp.OwnerId = u.Id;
                            }
                    }
                    if(opp.Portal_Account_Name__c != Null){
                        List<Account> AccList = [select Id, Name from Account where Name =: opp.Portal_Account_Name__c Limit 10000];
                        if(AccList.size() > 0){
                            for(Account a : AccList){
                                opp.AccountId = a.Id;
                            }
                        }
                    }
                }
            }
        }
        if(checkRecursive.checkOneTime()){
            for(opportunity oppAfter : trigger.New){
                if(rt_map.get(oppAfter.recordTypeID).getName().contains('CONECTIVIDAD') && oppAfter.Coming_from_Portal__c == True){
                    if(trigger.isAfter){
                        system.debug('--isAfter->>>>');
                        SBQQ__Quote__c quote = new SBQQ__Quote__c();
                        quote.SBQQ__Account__c = oppAfter.AccountId;
                        quote.Quote_Type__c = 'Draft';
                        quote.SBQQ__Opportunity2__c = oppAfter.Id;
                        quote.Requerimientos_del_cliente__c = 'PORTAL';
                        quote.SBQQ__PriceBook__c = '01s70000000JxjL';
                        quote.Primary_Contact__c = [Select Id from Contact where AccountId =: oppAfter.AccountId Order By createdDate Limit 1].Id;
                        if(oppAfter.PlazoContratacion__c != Null){
                            quote.SBQQ__SubscriptionTerm__c = oppAfter.PlazoContratacion__c;
                        }
                        quotelist.add(quote);
                        
                        if(oppAfter.Quote_line_Product_Name__c != Null){
                            for(Product2 p : [select Id, Name from Product2 where Name =: oppAfter.Quote_line_Product_Name__c]){
                                SBQQ__QuoteLine__c qli = new SBQQ__QuoteLine__c();
                                qli.SBQQ__Product__c = p.Id;
                                if(oppAfter.Product_Special_Price_coming_from_portal__c != Null){
                                    qli.SBQQ__SpecialPrice__c = oppAfter.Product_Special_Price_coming_from_portal__c;
                                }
                                qli.SBQQ__Quote__c = quote.Id;
                                qli.SBQQ__SpecialPriceType__c = 'Custom';
                                if(oppAfter.Quote_line_TipoClearChanel_Velocidad__c != Null){
                                    qli.TipoClearChanel__c = String.ValueOf(oppAfter.Quote_line_TipoClearChanel_Velocidad__c);    
                                }
                                quoteLineList.add(qli);
                            }
                            
                        }
                        SBQQ__QuoteLine__c qliNew = new SBQQ__QuoteLine__c();
                        qliNew.SBQQ__Product__c = '01t7000000Wt7xj';
                        qliNew.SBQQ__Quote__c = quote.Id;
                        qliNew.SBQQ__SpecialPriceType__c = 'Custom';
                        quoteLineDataServiceList.add(qliNew);
                    }
                }
            }
        }
        insert quotelist;
        insert quoteLineList;
        insert quoteLineDataServiceList;
    }
    if(trigger.isUpdate){
        .
		.
		.
    }
}

Please guys help me out !!
Hey folks,

I am generating pdf using visualforce page which is renderAs = 'PDF' and i have conditional pageblocktable are available in this pdf.

How can i insert this visualforce pdf in quote document ? However, i tried the following code but i am not able to save it conditional base.
 
public PageReference SaveQuoteDocument() {
                
        PageReference thePDF =  Page.PDFrecordPage;
        thePDF.getParameters().put('id',(String)this.Quote.Id);
        thePDF.setRedirect(true);


        if(!test.isrunningtest()){
            quotedocument qd = new quotedocument();
            qd.document = thePDF.getContentasPDF();
            qd.quoteId = this.Quote.Id;
            insert qd;
        }
        PageReference quotePage = new PageReference('/apex/DetailPage?id='+ this.Quote.Id);
        quotePage.setRedirect(true);
        return quotePage;
}

Can anyone please help me out !!

I am trying to achieve the following functionality using process builder but i am not getting it exactly what i need,

i have one custom field in opportunity called order(Text) and standard field Stage Now, i need to populate the number in order(Text) when stage is changed to closed/won and this need to be work for each opportunity which has the stage value closed/won..

i know we can achieve this by writing Apex trigger but here i have Professional Edition and i can not write any trigger or Workflow so, at last i have a choice to create process builder and achieve this functionality.

Can anybody please help me out here ?

Thanks
My client is going to buy 'Lightning Enterprise ($150/User)' and he need to reduce cost of other users and he want to buy 100 Users of 'Lightning Professional ($75/user)', After purchasing of these all users he needs to connect Lightning professional's User to Lightning EnterPrise Edition

Is it Possible way to reduce cost of salesforce licenses ?
Hi Experts,

Here i have one issue, i am not able to create new Quote record from custom commandButton which i declared in Visualforce page..

i do not want to predefined Opportunity from Lookup field..
What i want is when i click on Create New Quote Button (custom button from VF Page) then only allow me to create new Quote and at that i am going to select Opportunity manually from the lookup field.

Hope this is clear !!

Let me show you the URL which i am using in action of commandButton
 
<apex:commandButton value="Create New Quote" action="/0Q0/e?retURL=%2F0063600000D5oyO&oppid=0063600000D5oyO"/>

Now, What should i do to replace OpportunityID which is passed twice in above URL ?

Please Help !!

Thanks
Hello,

i am suddenly getting the following error in apex trigger :

"System.LimitException: Too many query rows: 50001"

Here is my apex trigger code :
 
trigger SetAmountfromOTTtoSFDC on Opportunity (Before Insert, Before Update) {
    
    Map <string, Id> AccountTextIdMap = new Map<String,Id>();
    Map <string, Id> ContactTextIdMap = new Map<String,Id>();
        
    
    if(Trigger.IsInsert || Trigger.IsUpdate){
        
        List<Account> AccList = [select Id, Name, AccountId__c from Account];
        for(Account ac : AccList){
            AccountTextIdMap.put(ac.AccountID__c, ac.id);
        }
        
        List<Contact> ConList = [select Id, Contact_ID__c from Contact];
        for(Contact con : ConList){
            ContactTextIdMap.put(con.Contact_ID__c, con.id);
        }
       
        for(Opportunity op : Trigger.New){

            if(op.AdrAccountSearchKey__c != Null && op.AccountId == Null){
                op.AccountId = AccountTextIdMap.get(op.AdrAccountSearchKey__c);
            }
            
            if(op.AdrContactSearchKey__c != Null && op.Contact__c == Null){
                op.Contact__c = ContactTextIdMap.get(op.AdrContactSearchKey__c);
            }
         }
}

I am using this trigger to set up the records which all are coming from other system using synchronization

i think Batch is very useful to this case but i am not sure how to do it, can somebody help me out

Thanks
Hello All,

I have written some code to insert Contact under Account based on text field which is common in both way..

for example : i have abc__c (text) field in Account and Contact, both have same value 'Text1'..if this is same for both way then insert that contact into that account which is matched with Account abc__c..

Please help me out and let me know if i need to go with another way..

Trigger Code :
trigger ContactInsertUnderAccount on Contact (after insert, after update)
{
    if (trigger.isAfter || trigger.isBefore)
    {
        List<Contact> toUpdate = new List<Contact>();
        for (Contact record : trigger.new)
            if (record.abc__c != null && record.AccountId == null)
                toUpdate.add(record);
        contactInsertUnderAccount.associateExternalAccount(toUpdate);
    }
}

Apex Class :
Public Class ContactInsertUnderAccount{
    public static void associateExternalAccount(List<Contact> contacts){
        List<Contact> toUpdate = new List<Contact>();
        for (Contact record : [select Id, abc__c from Contact])
        toUpdate.add(new Contact(Id=record.Id, Account = new Account(abc__c = record.abcl__c)));
        Database.update(toUpdate);
    }
}

Thanks..
Dear All,

Here i have the requirement to use FTP server in salesforce..

-- we have one external system and data inserted into it day by day
-- after that at the end of the day one file(.csv) automatically generated to that external system
-- How can i access of that file(.csv) from external system in salesforce using FTP server
-- after having that file's data i need to insert that data automatically(scheduled) in salesforce which is coming from external system

How can i achieve this ?

Please suggest the way..

Thanks
-Nihar
Hi All,

I am not able to see Contact selection screen while converting leads..

This is what i am expecting in Production (i'm able to see in sandbox) 

User-added image
what are the changes i have to make in production ?

HELP !!

Thanks
-Nihar
Hi,
i am trying to update the Stage based upon the Task.Status = 'Actividad-Finalizada'..and it worked if i have only one Task but i wont work if there are more task on same Opportunity..
Please can anybody check what change needs to this below code..
trigger UpdateOppOnTaskComplete on Task (after insert, after update) {

Set<String> whatIDs = new Set<String>();

for (Task t : Trigger.new) {
    if(t.Status.equals('Actividad-Finalizada'))
        whatIDs.add(t.whatID);
}

List<Opportunity> opps = [SELECT Id, StageName, Probability, Compania__c, Type  FROM Opportunity WHERE Id =: whatIDs AND (Probability = 98 OR Probability = 40) AND (Type = 'Flujo de venta Estándar' OR Type = 'Flujo de venta No Estándar')];

//List<Opportunity> opps1 = [SELECT Id, StageName, Probability, Compania__c  FROM Opportunity WHERE Id =: whatIDs AND Probability = 40 AND Type = 'Flujo de venta No Estándar'];

for(Opportunity opp : opps){
    if(opp.compania__c.equals('Bestel') && opp.Type.equals('Flujo de venta Estándar')){
        opp.StageName = 'Orden de Trabajo en proceso (99%)';
        opp.Probability = 99;
    }else if(opp.compania__c.equals('Metrored')) {
        opp.StageName = 'Cerrada (100%)';
        opp.Probability = 100;
    }
    if(opp.compania__c.equals('Bestel') && opp.Type.equals('Flujo de venta No Estándar')){
        opp.StageName = 'Producto define precio final (42 %)';
        opp.Probability = 42;
    }
}
if(opps != null && opps.Size() > 0)
update opps;
}

Thanks a ton !!
I am facing one issue and i don't know what is it, i am going to send and Email template to the Contact via Send Email Method but it will not working for Person Account...It is working for Business Account Perfectly.

Can anybody knows this...?

User-added image

Here is the Code : 
 
// Define the email
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); 
        List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
        // Reference the attachment page and pass in the account ID
        PageReference quotePdf = Page.PrintQuote;
        quotePdf.getParameters().put('id', quote.Id);
        quotePdf.setRedirect(true);

        // Take the PDF content
        Blob b= Test.isRunningTest() ? Blob.valueOf('UNIT.TEST') : quotePdf.getContent();
      /*  Blob  b;
       if (Test.IsRunningTest()){
            b=Blob.valueOf('UNIT.TEST');
           }
       else{
            b = quotePdf.getcontentAsPdf();
        }*/


        // Create the email attachment
        Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
        efa.setFileName( quote.Name + '.pdf');
        efa.setBody(b);
        fileAttachments.add(efa);

        Attachment att = new Attachment();
        att.body = b;
        att.Name = quote.Name + '.pdf';
        attList.add(att);

        for (Attachment a : [select Name, Body, BodyLength from Attachment where ParentId = :oppty.Id]) {
            // Add to attachment file list
            Messaging.Emailfileattachment opptyAttach = new Messaging.Emailfileattachment();
            opptyAttach.setFileName(a.Name);
            opptyAttach.setBody(a.Body);
            fileAttachments.add(opptyAttach);

            Attachment att1 = new Attachment();
            att1.body = a.Body;
            att1.Name = a.Name;
            attList.add(att1);
        }
        email.setFileAttachments(fileAttachments);

        //create dummy contact
        contact con = new contact();
        con.lastname = 'test con';
        con.Email = 'dummy@organization.com';
        con.accountid = quote.Opportunity__r.AccountId;
        insert con;

        email.setTemplateId( selectedTemplateId );
        email.setPlainTextBody(' ');
        email.setWhatId(oppty.id);
        email.setTargetObjectId(con.id);
        email.setToAddresses(new List<String>{quote.Opportunity__r.Account.Email__c});
        // Sends the email
        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
        if (r.get(0).isSuccess()) {
            //delete con;

            Task conTask = [Select Id, Subject, Description, Status, WhatId FROM Task WHERE WhoId =: con.Id];
            conTask.WhoId = null;
            update conTask;

            if(!attList.isEmpty()){
                for(Attachment attOne : attList){
                    attOne.ParentId = conTask.Id;
                }

                insert attList;
            }
            delete con;
        }

    } catch(Exception ex){
        system.debug('@@ex : '+ ex.getMessage());
    }
    return null;

Here is the Debug Log :
 
17:59:45.365 (365289954)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
17:59:45.374 (374242038)|DML_END|[80]
17:59:45.374 (374345877)|VF_PAGE_MESSAGE|Can not select a person account
17:59:45.374 (374455141)|EXCEPTION_THROWN|[80]|System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Can not select a person account: [AccountId]
17:59:45.374 (374871091)|HEAP_ALLOCATE|[80]|Bytes:131
17:59:45.374 (374911869)|VARIABLE_SCOPE_BEGIN|[106]|ex|Exception|true|false
17:59:45.375 (375008887)|VARIABLE_ASSIGNMENT|[106]|ex|"common.apex.runtime.impl.DmlExecutionException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Can not select a person account: [AccountId]"|0xb720d38
17:59:45.375 (375020072)|STATEMENT_EXECUTE|[106]
17:59:45.375 (375023602)|STATEMENT_EXECUTE|[107]
17:59:45.375 (375028953)|HEAP_ALLOCATE|[107]|Bytes:7
17:59:45.375 (375092756)|HEAP_ALLOCATE|[107]|Bytes:127
17:59:45.375 (375115362)|HEAP_ALLOCATE|[107]|Bytes:134
17:59:45.375 (375137936)|USER_DEBUG|[107]|DEBUG|@@ex : Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Can not select a person account: [AccountId]
17:59:45.375 (375148335)|STATEMENT_EXECUTE|[109]
17:59:45.375 (375537174)|CODE_UNIT_FINISHED|SendEmailWithAttachmentsController invoke(sendEmail)
17:59:45.376 (376134040)|VF_APEX_CALL|j_id30|{!sendEmail}|PageReference: none
17:59:45.380 (380563876)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:5
17:59:45.380 (380574167)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:16
17:59:45.380 (380589584)|VARIABLE_ASSIGNMENT|[-1]|this.conSeverity|"ERROR"|0x59d07d55
17:59:45.380 (380706672)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
17:59:45.380 (380713611)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:16
17:59:45.380 (380724950)|VARIABLE_ASSIGNMENT|[-1]|this.conStrength|2|0x59d07d55
17:59:45.388 (388891596)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:5
17:59:45.388 (388901003)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:16
17:59:45.388 (388919195)|VARIABLE_ASSIGNMENT|[-1]|this.conSeverity|"ERROR"|0x59d07d55
17:59:45.389 (389015758)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
17:59:45.389 (389021441)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:16
17:59:45.389 (389031672)|VARIABLE_ASSIGNMENT|[-1]|this.conStrength|2|0x59d07d55

Thank you in Advance....
Hello,

I am trying to get more then 75% code coverage for my custom class but dont know why i am getting stucked.

Here is my class :
 
public class CreatePaymentController {
    
    String opportunityId = '';
    public String selectedInvoiceId {get; set;}
    public List<SelectOption> options {get; set;}
    List<Invoice__c> relatedInvoiceList = new List<Invoice__c>();
    
    public CreatePaymentController(){
        
        selectedInvoiceId = '';
        options = new List<SelectOption>();
        opportunityId = Apexpages.Currentpage().getparameters().get('opptyId');
        relatedInvoiceList = [select Id,Name from Invoice__c where Opportunity__c =:opportunityId];
    }
    
    public Pagereference redirectToPaymentDetail(){
        
        Payment__c payment;
        try{
            
            if(relatedInvoiceList <> null && relatedInvoiceList.size() == 1){
                List<Payment__c> paymentList = [Select Id,Name from Payment__c where Invoice__c =:relatedInvoiceList[0].Id];
                if(paymentList <> null && paymentList.size() > 0){
                    payment = new Payment__c(Id=paymentList[0].Id);
                }
                else{
                    payment = new Payment__c();
                    payment.Invoice__c = relatedInvoiceList[0].Id;
                    upsert payment;
                }
                Payment__c pay = [select Id, Name From Payment__c WHERE Id =:payment.Id];
                PageReference newPaymentDetailPage = new PageReference('/a08/e?CF00N2400000FhfdZ='+pay.Name+'&CF00N2400000FhfdZ_lkid='+pay.Id+'&saveURL=/'+opportunityId);
                newPaymentDetailPage.setRedirect(true);
                return newPaymentDetailPage;
            }
            else if(relatedInvoiceList <> null && relatedInvoiceList.size() > 1){
                
                for (Invoice__c inv : relatedInvoiceList) {
                    
                    options.add(new SelectOption(inv.Id, inv.Name));
                }
                system.debug('@@options : '+ options);
            }
        } catch(Exception ex){
            system.debug('@@ex : '+ ex.getMessage());
        }
        return null;
    }
    
    public PageReference paymentPage(){
        try{
            if(!String.isBlank(selectedInvoiceId)){
                Payment__c payment =  new Payment__c();
                payment.Invoice__c = selectedInvoiceId;
                insert payment;
                Payment__c pay = [select Id, Name From Payment__c WHERE Id =:payment.Id];
                PageReference newPaymentDetailPage = new PageReference('/a08/e?CF00N2400000FhfdZ='+pay.Name+'&CF00N2400000FhfdZ_lkid='+pay.Id+'&saveURL=/'+opportunityId);
                newPaymentDetailPage.setRedirect(true);
                return newPaymentDetailPage;
            }
        } catch(Exception ex){
            system.debug('@@ex : '+ ex.getMessage());
        }
        return null;
    }
}

Here is Test Class :
 
@isTest(SeeAllData=true)
public class CreatePaymentControllerTest{

    static testMethod void MyTest(){
        
        Account a = new Account();        
        a.Name = 'test';
        a.Email__c = 'test@test.com';
        a.CurrencyIsoCode = 'EUR';
        a.Phone = '789642';
        a.BillingCity= 'bhuj';
        a.BillingPostalCode = '370001';
        a.BillingCountry = 'india';
        a.BillingLatitude = 57.5 ;
        a.BillingLongitude = 67.7;
        a.BillingState = 'Gujarat';
        a.BillingStreet = 'Main';
        insert a;
         
        Opportunity opp = new Opportunity();
        opp.Name = 'Test Opportunity';
        opp.StageName = 'Stage 0';
        opp.CloseDate = system.today().addDays(10);
        opp.Accountid = a.id;
        opp.CurrencyIsoCode = 'GBP';
        insert opp;
        
        Invoice__c inv = new Invoice__c();
        inv.Account_Name__c = a.id;
        inv.Opportunity__c = opp.id;
        inv.CurrencyIsoCode = 'GBP';
        insert inv;
        
        Payment__c pm = new Payment__c();
        pm.Invoice__c = inv.id;
        pm.CurrencyIsoCode = 'GBP';
        insert pm;
        
        Payment__c pm1 = new Payment__c();
        pm1.Invoice__c = inv.id;
        pm1.CurrencyIsoCode = 'GBP';
        insert pm1;
        
        PageReference pageRef = new Pagereference('/a08/e?CF00N2400000FhfdZ=pm.Name&CF00N2400000FhfdZ_lkid=pm.Id&saveURL=/opp.Id');
        Test.setCurrentPage(pageRef);

        CreatePaymentController cnt = new CreatePaymentController();
        
        cnt.paymentPage();
        
        Apexpages.currentPage().getParameters().put('id',opp.Id); 
        
        cnt.redirectToPaymentDetail();
    
    }
}

Thanks in Advance..
I am inserting Invoice based on my attendees object and inserting Invoice Line item based on that Invoice that is already created.

so, My question is if the user will select multiple attendees, many of those might be at the same account, so we’ll make only one invoice for each account, but there will be an Invoice Line Item for each attendee.

This account is selected as per the contact of attendees record.

Please suggest me how can i do this.

Here is my code :
Public PageReference save(){

        invList = new List<Invoice__c>();
        invLineList = new List<Invoice_Line__c>();
        List<Attendee__c> attendeeUpdate = new List<Attendee__c>();

        Map<String,Attendee__c> invoiceAttendee = new Map<String,Attendee__c>();

        for(Attendee__c a : atList){

            Invoice__c inv = new Invoice__c();

            inv.Billed_Through__c = a.Function__r.Billed_Through__c;
            inv.Invoice_Memo__c = a.Function__r.Name;
            inv.Customer__c = a.Contact__c;
            inv.Invoice_Date__c = date.today();
            inv.AtndID__c = a.Id;
            invList.add(inv);
            invoiceAttendee.put(a.Id,a);
        }

        insert invList;

        for(Invoice__c inv : invList){
            if(invoiceAttendee.get(inv.AtndID__c) != null){
                invoiceAttendee.get(inv.AtndID__c).Invoice__c = inv.Id;
            }
        }

        update invoiceAttendee.values();

        for(Invoice__c i : invList){

            invLine = new Invoice_Line__c();
            invLine.Line_Description__c = ' Attendance of ' + invoiceAttendee.get(i.AtndID__c).Contact__r.Name  + ' at '+  invoiceAttendee.get(i.AtndID__c).Function__r.Name;
            invLine.Line_Total__c =  invoiceAttendee.get(i.AtndID__c).Attendee_Charge__c;
            invLine.invoice__c = i.Id;
            invLineList.add(invLine);
            if(invIDs == null){
                invIDs = i.id;
            }else{
                invIDs += ',' + i.id;  
            }

        }

        insert invLineList;
Hi all,

Using Apex, did you ever had to subtract the business days from any given date? 
Like for ex: if I have to subtract from today Estimated_Ship_Week__c(e.g 9/1/2015) - Mfg_Cycle_Time_Target__c (12)(This is Number field) days, it should exclude all the weekends and give me the final date 9/14/2015 .
Please let me know if you have any function related to this requirement.
Thanks for looking into this.

Regards,
Nihar
I am not able to see fields of event & task (Activity) in sites that i have created.
I already check all of the permission for each fields as well and from sites i checked Public Access Setting too (It is OK.)
but don't know why i am not able to see.

Thank you.
Hi,

Can anybody please tell me the field name of Recipient type of EMAIL in Echosign Agreement ?
i have found the another three like (Contact, User, Lead) But do not getting idea about 'EMAIL'.
I need this name because i have write a trigger on agreement object and replace that field with the opportunity's field.

Thank you in Advance.
Hi All,

My question is regarding Save Pdf as in Notes and Attachment under the record,

So, my issue is,

First controller is fill the document(PDF) and Second controller can Save that PDF using that first Controller, How can i Do this ?

Or any other solution to save this PDF in Notes and Attachment ?

Please Help..

Thank you.
Hi,
i have created one button on record top beside the clone button,
when clicked, execute code that would make a new version record with the same name and append today's date on the end of the name to distinguish it from the original.

How should i do this ?

Thank you very much in advance
I have built following apex trigger code and isAfter code is not executing because I have used recursive method in this trigger.

Please have a look into this and let me know what i have did wrong in this code :
 
trigger CreateOrderForOpportunity on Opportunity (before insert, after insert, after update) {
    
    if(trigger.isInsert){
        
        Map<ID,Schema.RecordTypeInfo> rt_Map = Opportunity.sObjectType.getDescribe().getRecordTypeInfosById();
        List<SBQQ__Quote__c> quotelist = new List<SBQQ__Quote__c>();
        List<SBQQ__QuoteLine__c> quoteLineList = new  List<SBQQ__QuoteLine__c>();
        List<SBQQ__QuoteLine__c> quoteLineDataServiceList = new  List<SBQQ__QuoteLine__c>();
        
        for(Opportunity opp : trigger.New){
            
            if(rt_map.get(opp.recordTypeID).getName().contains('CONECTIVIDAD') && opp.Coming_from_Portal__c == True){
                
                if(trigger.isBefore){
                    if(opp.Owner_Email_Address_coming_from_portal__c != Null){
                        List<user> uList = [select Id, Email from user where Email =: opp.Owner_Email_Address_coming_from_portal__c Limit 1];
                        if(uList.size() > 0)
                            for(User u : uList){
                                opp.OwnerId = u.Id;
                            }
                    }
                    if(opp.Portal_Account_Name__c != Null){
                        List<Account> AccList = [select Id, Name from Account where Name =: opp.Portal_Account_Name__c Limit 10000];
                        if(AccList.size() > 0){
                            for(Account a : AccList){
                                opp.AccountId = a.Id;
                            }
                        }
                    }
                }
            }
        }
        if(checkRecursive.checkOneTime()){
            for(opportunity oppAfter : trigger.New){
                if(rt_map.get(oppAfter.recordTypeID).getName().contains('CONECTIVIDAD') && oppAfter.Coming_from_Portal__c == True){
                    if(trigger.isAfter){
                        system.debug('--isAfter->>>>');
                        SBQQ__Quote__c quote = new SBQQ__Quote__c();
                        quote.SBQQ__Account__c = oppAfter.AccountId;
                        quote.Quote_Type__c = 'Draft';
                        quote.SBQQ__Opportunity2__c = oppAfter.Id;
                        quote.Requerimientos_del_cliente__c = 'PORTAL';
                        quote.SBQQ__PriceBook__c = '01s70000000JxjL';
                        quote.Primary_Contact__c = [Select Id from Contact where AccountId =: oppAfter.AccountId Order By createdDate Limit 1].Id;
                        if(oppAfter.PlazoContratacion__c != Null){
                            quote.SBQQ__SubscriptionTerm__c = oppAfter.PlazoContratacion__c;
                        }
                        quotelist.add(quote);
                        
                        if(oppAfter.Quote_line_Product_Name__c != Null){
                            for(Product2 p : [select Id, Name from Product2 where Name =: oppAfter.Quote_line_Product_Name__c]){
                                SBQQ__QuoteLine__c qli = new SBQQ__QuoteLine__c();
                                qli.SBQQ__Product__c = p.Id;
                                if(oppAfter.Product_Special_Price_coming_from_portal__c != Null){
                                    qli.SBQQ__SpecialPrice__c = oppAfter.Product_Special_Price_coming_from_portal__c;
                                }
                                qli.SBQQ__Quote__c = quote.Id;
                                qli.SBQQ__SpecialPriceType__c = 'Custom';
                                if(oppAfter.Quote_line_TipoClearChanel_Velocidad__c != Null){
                                    qli.TipoClearChanel__c = String.ValueOf(oppAfter.Quote_line_TipoClearChanel_Velocidad__c);    
                                }
                                quoteLineList.add(qli);
                            }
                            
                        }
                        SBQQ__QuoteLine__c qliNew = new SBQQ__QuoteLine__c();
                        qliNew.SBQQ__Product__c = '01t7000000Wt7xj';
                        qliNew.SBQQ__Quote__c = quote.Id;
                        qliNew.SBQQ__SpecialPriceType__c = 'Custom';
                        quoteLineDataServiceList.add(qliNew);
                    }
                }
            }
        }
        insert quotelist;
        insert quoteLineList;
        insert quoteLineDataServiceList;
    }
    if(trigger.isUpdate){
        .
		.
		.
    }
}

Please guys help me out !!
Hey folks,

I am generating pdf using visualforce page which is renderAs = 'PDF' and i have conditional pageblocktable are available in this pdf.

How can i insert this visualforce pdf in quote document ? However, i tried the following code but i am not able to save it conditional base.
 
public PageReference SaveQuoteDocument() {
                
        PageReference thePDF =  Page.PDFrecordPage;
        thePDF.getParameters().put('id',(String)this.Quote.Id);
        thePDF.setRedirect(true);


        if(!test.isrunningtest()){
            quotedocument qd = new quotedocument();
            qd.document = thePDF.getContentasPDF();
            qd.quoteId = this.Quote.Id;
            insert qd;
        }
        PageReference quotePage = new PageReference('/apex/DetailPage?id='+ this.Quote.Id);
        quotePage.setRedirect(true);
        return quotePage;
}

Can anyone please help me out !!

I am trying to achieve the following functionality using process builder but i am not getting it exactly what i need,

i have one custom field in opportunity called order(Text) and standard field Stage Now, i need to populate the number in order(Text) when stage is changed to closed/won and this need to be work for each opportunity which has the stage value closed/won..

i know we can achieve this by writing Apex trigger but here i have Professional Edition and i can not write any trigger or Workflow so, at last i have a choice to create process builder and achieve this functionality.

Can anybody please help me out here ?

Thanks
My client is going to buy 'Lightning Enterprise ($150/User)' and he need to reduce cost of other users and he want to buy 100 Users of 'Lightning Professional ($75/user)', After purchasing of these all users he needs to connect Lightning professional's User to Lightning EnterPrise Edition

Is it Possible way to reduce cost of salesforce licenses ?
Hi Experts,

Here i have one issue, i am not able to create new Quote record from custom commandButton which i declared in Visualforce page..

i do not want to predefined Opportunity from Lookup field..
What i want is when i click on Create New Quote Button (custom button from VF Page) then only allow me to create new Quote and at that i am going to select Opportunity manually from the lookup field.

Hope this is clear !!

Let me show you the URL which i am using in action of commandButton
 
<apex:commandButton value="Create New Quote" action="/0Q0/e?retURL=%2F0063600000D5oyO&oppid=0063600000D5oyO"/>

Now, What should i do to replace OpportunityID which is passed twice in above URL ?

Please Help !!

Thanks
Hello,

i am suddenly getting the following error in apex trigger :

"System.LimitException: Too many query rows: 50001"

Here is my apex trigger code :
 
trigger SetAmountfromOTTtoSFDC on Opportunity (Before Insert, Before Update) {
    
    Map <string, Id> AccountTextIdMap = new Map<String,Id>();
    Map <string, Id> ContactTextIdMap = new Map<String,Id>();
        
    
    if(Trigger.IsInsert || Trigger.IsUpdate){
        
        List<Account> AccList = [select Id, Name, AccountId__c from Account];
        for(Account ac : AccList){
            AccountTextIdMap.put(ac.AccountID__c, ac.id);
        }
        
        List<Contact> ConList = [select Id, Contact_ID__c from Contact];
        for(Contact con : ConList){
            ContactTextIdMap.put(con.Contact_ID__c, con.id);
        }
       
        for(Opportunity op : Trigger.New){

            if(op.AdrAccountSearchKey__c != Null && op.AccountId == Null){
                op.AccountId = AccountTextIdMap.get(op.AdrAccountSearchKey__c);
            }
            
            if(op.AdrContactSearchKey__c != Null && op.Contact__c == Null){
                op.Contact__c = ContactTextIdMap.get(op.AdrContactSearchKey__c);
            }
         }
}

I am using this trigger to set up the records which all are coming from other system using synchronization

i think Batch is very useful to this case but i am not sure how to do it, can somebody help me out

Thanks
Hello All,

I have written some code to insert Contact under Account based on text field which is common in both way..

for example : i have abc__c (text) field in Account and Contact, both have same value 'Text1'..if this is same for both way then insert that contact into that account which is matched with Account abc__c..

Please help me out and let me know if i need to go with another way..

Trigger Code :
trigger ContactInsertUnderAccount on Contact (after insert, after update)
{
    if (trigger.isAfter || trigger.isBefore)
    {
        List<Contact> toUpdate = new List<Contact>();
        for (Contact record : trigger.new)
            if (record.abc__c != null && record.AccountId == null)
                toUpdate.add(record);
        contactInsertUnderAccount.associateExternalAccount(toUpdate);
    }
}

Apex Class :
Public Class ContactInsertUnderAccount{
    public static void associateExternalAccount(List<Contact> contacts){
        List<Contact> toUpdate = new List<Contact>();
        for (Contact record : [select Id, abc__c from Contact])
        toUpdate.add(new Contact(Id=record.Id, Account = new Account(abc__c = record.abcl__c)));
        Database.update(toUpdate);
    }
}

Thanks..
Good afternoon, all!
We’re experiencing a recurring problem with the Jitterbit Data Loader (free version) completing transactions with SalesForce and were wondering if you could point us in the right direction to figuring it out. The job that fails is a query that is designed to call on SalesForce and return a list of about 300,000 records.  Nothing more.  Just 300,000 records of two fields, each. Of course, the query then dumps these records into a *.csv file and saves it to our computer. Later, another process uses that file to determine which records to delete before wiping it out. An query this small should not be subject to query time out, right?

A further wrinkle is this:  the query only fails intermittently.  The query is set to run on a schedule at 0400 (a slow time for our network) and fails to execute about 70% of the time.  When the query is manually run during the more busy times of regular business hours, it usually fails the first time and sometimes a second time, but it usually goes through with no difficulty after that.  It puzzles me. 

Here is the error from Jitterbit:

Message:
The operation "02:00 AM PFA SF Labor to Delete Daily" failed.
Fatal Error:
Transformation failed.

Error:
Call to webservice at https://na5.salesforce.com/services/Soap/u/33.0/00D700000008pkL failed. Reported error:

The webservice call failed. The web service returned a SOAP Fault:

Code: sf:QUERY_TIMEOUT

Message: QUERY_TIMEOUT: Your query request was running for too long.



Detail: QUERY_TIMEOUTYour query request was running for too long.


Additional details:

Failed to call the web service at "https://na5.salesforce.com/services/Soap/u/33.0/00D700000008pkL".

Reason: The last (and probably most relevant) error was:

The server returned HTTP Status Code : 500 Server Error



Error is: The server encountered an unexpected condition that prevented it from fulfilling the request.

Headers sent by the server:

HTTP/1.1 500 Server Error

Date: Sun, 24 Jan 2016 08:00:11 GMT

Set-Cookie: BrowserId=X-jKMkB4R9WaDbJGUkp8QQ;Path=/;Domain=.salesforce.com;Expires=Thu, 24-Mar-2016 08:00:11 GMT

Expires: Thu, 01 Jan 1970 00:00:00 GMT

Content-Type: text/xml;charset=UTF-8

Transfer-Encoding: chunked





(The posted soap envelope was: 'C:/Windows/Temp/jitterbit_dl6/OpId_664036_3d643f48-b011-466d-970b-72565749b349/_t755836_target_req.xml'.) [CODE:10721] file: WebServiceHandler.cpp, line 997 [CODE:10104] file: TreeMapperWebService.cpp, line 142

Is there any way to resolve this issue?

Thanks,
Stephen D. Cox

Hi All,

 

 

I need to write a trigger to update the Task Status to 'Completed' . when the Lead is converted to Opportunity.

Please help me to sort out this issue

 

regards,

Anni

 

 

  • December 04, 2012
  • Like
  • 0
Need to integrate BRM i.e Billing Revenue Managment with Salesforce.
How can I achieve this?