• Deepak Kumar Shyoran
  • PRO
  • 2314 Points
  • Member since 2013
  • Sr. Software Developer
  • Briskminds Soft. Solutions

  • Chatter
    Feed
  • 72
    Best Answers
  • 2
    Likes Received
  • 3
    Likes Given
  • 2
    Questions
  • 544
    Replies
I have a trigger that should only update quotes if the opportunity record type is 'NA Opportunity Record Type' . I've tried to add it into the trigger but nothing has worked. Any help would be greatly appreciated. 

 


trigger Trigger_MarkPrimaryQuote on Quote (before insert) {
    
 // 
 List<String> oracleQuoteList = new List<String>();
    for(Quote qRec : Trigger.new) {
        qRec.Primary_Quote__c = true;
        oracleQuoteList.add(qRec.Oracle_Quote__c);      
    }
 //   
    List<Quote> quoteListToUpdate = new List<Quote>();
    for(Quote qRec : [SELECT id,Primary_Quote__c,Oracle_Quote__c,Opportunity.RecordType.Name   from Quote WHERE Oracle_Quote__c IN : oracleQuoteList]) {
        qRec.Primary_Quote__c =false;
        qRec.Opportunity.RecordType.Name ='NA Opportunity Record Type';
        quoteListToUpdate.add(qRec);    
    }
//    
    if(quoteListToUpdate != null && quoteListToUpdate .size() > 0) {
        update quoteListToUpdate;
    }

 }

 
Hi Team,

I've asked similar question, but answer did not solve issue.  Is this an order of execution thing or something like that???
See below,  where I tried by ultimate goal of condition based on RecordType.Name,  even tried  a simple IF (1=2)  and I still get ALL of the selectOption displayed.

What is the proper technique for this????
Thanks.

I am using this...
<apex:page standardController="MyCustom__c" sidebar="false">
.....
 <apex:form >
....
<apex:pageBlockSection title="Build PickList">
......
<apex:selectList >
    { ! IF (1=2)
    {
     <apex:selectOption itemLabel="1=1" itemValue="1=1"/>
    }
    }
.....
ultimate goal is this conditional,  but even the IF (1=2) does not seem to execute properly
I DO get the MyCustom__c.RecordType.Name A-OK.
However,  the IF seems to fail,  because I get ALL THREE selectOption displayed every time.

{ !IF 
           (CONTAINS (MyCustom__c.RecordType.Name,"Hiring"),
           {
           <apex:selectOption itemLabel="Initial Contact for Hiring Need" itemValue="Initial Contact"/>
           <apex:selectOption itemLabel="Follow-up Contact for Hiring Need" itemValue="Followup Contact"/>}
           , 
           
           {  <apex:selectOption itemLabel="NOT Hiring Need" itemValue="NOT Hiring Need"/>}
           )
        } 

  </apex:selectList>


 
Currently we have an application with much data in the oracle database, and we are going to migrate our applicatoin to salesforce, e.g. with lightning app, lightning component, but we can't import our data into salesforce due to our company policy, so I would like to ask, could we just make a jdbc connection to our oracle database from salesforce lightning compoent?
Hi, 

I have some methods one method for loop calling another method, that method having query and return values. some times causing error message like Too many SOQL queries: 101 . How to avoid this, my sample code is below. Guide me to Solve this issue . Where i have to  change my code .

 public List<MarkSheetDomain> getMarksheet(){        
        List<AggregateResult> subjectCodes = new List<AggregateResult>();
        List<MarkSheet> marks = new List<MarkSheet>();
        SemesterSelection = string.escapesinglequotes(SemesterSelection);
        subjectCodes = [Select Subject_Code__c code from catalog__c where Paper__c ='Maths'  And Subject_Code__c != null GROUP BY Subject_Code__c];        
        for (AggregateResult subjectcode : subjectCodes){
            MarkSheet mark = new MarkSheet();
            mark.SubjectCode = String.valueOf(subjectcode.get('code'));        
            mark.ExternalExam = getExternalExams(mark.SubjectCode);           
            marks.add(mark);
        }
        return marks;
    }    
    public String getExternalExams(string Subjectcode) {  
        RollNo = string.escapesinglequotes(RollNo);  
        External_Exam__c ExtExm = new External_Exam__c();
        ExtExm = [Select Title__c, Score__c from External_Exam__c where Sem__c=:SemesterSelection And Subject_Code__c =:Subjectcode and Student__r.Roll_No__c =:RollNo];
        System.debug('Test on Mark' + ExtExm );
        System.debug('Test on Mark' + ExtExm.Score__c);
        return String.valueOf(ExtExm.Score__c);         
    }

Advance Thanks
Maheshwar
Hi, I'm trying to write into a field, Actuals_P1_MOR__c, the number 100 (for example). This field belong to Pipeline_Item__c object. So, at the end, I update the List pl that is made of Pipeline_Item__c records, in order to update every Actuals_P1_MOR__c.

But I get this error:

System.LimitException: DML currently not allowed 
 
for (Pipeline_Item__c p : pl)
            {
                
                if (p.Actual_P1_MOR__c== null){
                    p.Actual_P1_MOR__c=0;
                }

                if (p.Pipeline__r.CurrencyIsoCode=='USD')
                {
                    p.Rate_to_USD__c=1;

                } else {

                    p.USD_MOR_1__c=morMap.get('January');
                    p.USD_MOR_2__c=morMap.get('February');
                    p.USD_MOR_3__c=morMap.get('March');

                    
                
                 if (p.Pipeline__r.CurrencyIsoCode=='EUR')
                {
                    String cic = 'EUR';
                    
                    p.Rate_to_USD__c= bemap.get(cic);
                   

                }
                else if (p.Pipeline__r.CurrencyIsoCode=='BRL')
                {
                    String cic = 'BRL';
                    
                    p.Rate_to_USD__c= bemap.get(cic);
                }
                else if (p.Pipeline__r.CurrencyIsoCode=='CAD')
                {
                    String cic = 'CAD';
                    
                    p.Rate_to_USD__c= bemap.get(cic);
                }
                else if (p.Pipeline__r.CurrencyIsoCode=='PLN')
                {
                    String cic = 'PLN';
                    
                    p.Rate_to_USD__c= bemap.get(cic);
                }
                else if (p.Pipeline__r.CurrencyIsoCode=='GBP')
                {
                    String cic = 'GBP';
                    
                    p.Rate_to_USD__c= bemap.get(cic);
                }
            }

                if (p.Estimate1__c != null)
                q.Estimate__c += p.Estimate1__c* p.Rate_to_USD__c;

                if (p.Op_P1__c != null)
                q.OP__c += p.Op_P1__c* p.Rate_to_USD__c;

                if (p.Op_P2__c != null)
                q.OP__c += p.Op_P2__c* p.Rate_to_USD__c;

                if (p.Op_P3__c != null)
                q.OP__c += p.Op_P3__c* p.Rate_to_USD__c;

                
                
                if (p.Actual_P1__c != null){                       
                    q.Month1__c += p.Actual_P1__c* p.Rate_to_USD__c;
                    
                    if (p.USD_MOR_1__c != null){
                        
                        q.Month1MOR__c += p.Actual_P1__c*p.USD_MOR_1__c;
                        p.Actual_P1_MOR__c += 100;
                       
                        
                    } else {
                        q.Month1MOR__c = q.Month1__c;

                    }               
                }

                if (p.Actual_P2__c != null){
                q.Month2__c += p.Actual_P2__c* p.Rate_to_USD__c;
                    if (p.USD_MOR_2__c != null){
                        q.Month2MOR__c += p.Actual_P2__c*p.USD_MOR_2__c;
                    } else {
                        q.Month2MOR__c = q.Month2__c;
                    }            
                }
                if (p.Actual_P3__c != null) {
                q.Month3__c += p.Actual_P3__c* p.Rate_to_USD__c;
                    if (p.USD_MOR_3__c != null){
                        q.Month3MOR__c += p.Actual_P3__c*p.USD_MOR_3__c;
                    } else {
                        q.Month3MOR__c = q.Month3__c;
                    }         
               }


            } 

            update pl;             <---------------------------------

Any idea?

Thankyou!
 In a picklist, I want to display US, UK on the top and rest should be alphabetical order? How can we achieve this?
Hi All,

Popup alert

Could someone please let us know if it is possible to remove the message " This Page at https://salesforce.com Says" from the pop up page. this is the normal javascript alert message.

Thank you,

Regards,
Christwin




 
Hi All,

Could someone please let us know if it is possible to increase the width of the standard button "New" in the list view.

Thank you,

Regards,
Christwin
In my assignment related to salesforce i got one problem that is when i save and execute code in developer console it is running fine but when i write same code inside ape class then i am getting problem like update api version so how to solve this problem.
Hi ,

can any one suggest we have a standard object called case.we have a field called VIn no in case object.
whenever new case is created with account name and contact name,based on account name and contact name VIN should be populated.

Can anyone suggest how can i do this to get VIN no populated and VIN field is lookup here
I have a visualforce component that is used to allow users to enter in their information.  It contains Country and State.  When Country is selected I want only the State to be rerendered and not the whole page again.  I seem to only be able to get all if it to rerender or nothing.  How do I rerender a inputfield in the component when it gets changes?
HI, am receiving the following error message when making any changes to an opportunity:

Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger OpportunityTriggers caused an unexpected exception, contact your administrator: OpportunityTriggers: execution of AfterUpdate caused by: System.NullPointerException: Attempt to de-reference a null object: Class.OpportunityTriggerHandler.closeOpportunitiesWithSameSpaceController: line 424, column 1.

Any suggestions on how to fix?

thanks in advance. 
Hi, 
I have a requirement to assign a Q1/Q2/Q3/Q4 to an opportunity in a custom field for reporting purposes. 

My finanical year and Quarter 1 start date is the first Thursday of each July (cinema company in Australia).

I'm completley new and although I have sifted through allot of discussions on here can't seem to find my solution. 

Is anyone able to assist? 


 
Hi,
 I have a blank page with an action method that performs some database inserts and finally after that I need to close this window.
 
following is my code.my page has only the following code:

<apex:page action="{!generatePDF}"  controller="VFC_ER_GeneratePDF"  showheader="false"  standardStylesheets="false" >
</apex:page>

In the controller 'VFC_ER_GeneratePDF' I have a method called generatePDF with the following code.  and finally after that I want to close this window. How do I do that pls help...

public class VFC_ER_GeneratePDF {
    public string  sigID;
    public string ERID;
    
    public VFC_ER_GeneratePDF() {
        
        sigID = System.currentPageReference().getParameters().get('sigID'); 
        ERID = System.currentPageReference().getParameters().get('id'); 

    }
    
      public pageReference  generatePDF() {
      
      PageReference pdf = New PageReference ('/apex/'+ 'vf_SignatureCaptured');
        // add parent id to the parameters for standardcontroller
        pdf.getParameters().put('id',ERID);
        pdf.getParameters().put('sigID',sigID);
      
        // create the new attachment
        Attachment attach = new Attachment();
     
        // the contents of the attachment from the pdf
        Blob body;
     
        try {
                // returns the output of the page as a PDF
                body = pdf.getContentAsPDF();
            }
          catch (VisualforceException e) 
            {
                // need to pass unit test -- current bug  
                body = Blob.valueOf('Some Text');
            }
     
        attach.Body = body;
        attach.Name = ERId + '.pdf';
        attach.IsPrivate = false;
        attach.ParentId = ERId;
        insert attach;
        system.debug('Final Attachement' + attach);
          
        //delete the signature attachment 
          List<Attachment> attachedFiles = [select Id from Attachment where id =:sigID limit 1];
        if( attachedFiles != null && attachedFiles.size() > 0 ) 
        {
           delete attachedFiles;
        }  
        
        //this is where I need to close this window.
      
      }      
  
}
 
Hi,
Why is the user role displayed as a required field on the user detail page even though the validation  is not enforced on the same?
 
can abybody let me know basic difference with an exmple about the diffrence
Hi All,
     I am new to SFDC and i have written one trigger but i'm not able to write test class for it someone please tell me how can i write test class  for this trigger my Trigger is

trigger FetchVatvalue on Quote__c (before insert,before update) 
{
    //create reference table for lookup value
    Map<String, Decimal> vatMap = new Map<String, Decimal>();
    //build reference table for VAT rates
    for (VAT__c vat : [SELECT Name,Vat_Rate__c FROM VAT__c])
        vatMap.put(vat.Name, vat.Vat_Rate__c);
    //update Quote__c with VAT rate
    for (Quote__c q : trigger.new)
    {
        Decimal vatRate = vatMap.get(q.Country_Code__c);
        q.VAT_Rate__c = vatRate;
    }
}

this trigger is wrtten for automaticaly fetch value from another object using picklist

thank you,
Sam