• Manojjena
  • ALL STAR
  • 6387 Points
  • Member since 2012
  • Lead Consultant
  • Itc infotech

  • Chatter
    Feed
  • 194
    Best Answers
  • 1
    Likes Received
  • 6
    Likes Given
  • 24
    Questions
  • 1476
    Replies
i Have created the handler for that in the text filed  i want the name but populated the id  following is my code

public class Populatedlookup {


    Public void updateField(List<Lead> leadList){
        /*
        for(lead l : leadList){
            leadId.add(l.Id);
            System.debug('leadid'+ leadId.add(l.Id));
        }
        lead leadOne = [select id, name, Channel_Partner__c from lead where Id IN: leadId];
        if(leadOne.Channel_Partner__c!=null){
        Distributor__c dis = [select id, name from Distributor__c where Id=:leadOne.Channel_Partner__c];
        DistributorName = dis.Name;
*/
        for(Lead leadObj:LeadList){
            if(leadObj.Channel_Partner__c!=null){
                leadObj.Channel_Partner_Text__c=leadObj.Channel_Partner__r.Name;
            }
            else{
                leadObj.Channel_Partner_Text__c='';
            }
            
        }
      
    }
}
Hi Friends,

Please help on below Trigger. I am trying to insert Quote when the attachment is added to Opporunity and the file name contains PDF.

trigger oppattachment on Attachment (after insert, after update) {
    
    Set <Id> oppIds = new Set <Id>();    
    for(Attachment attach : Trigger.new) {
        if(attach.ParentId.getSobjectType() == Opportunity.SobjectType) {
            if(string.valueOf(attach.Name).contains('.pdf')) {
                oppIds.add(attach.ParentId);
            }
        }
    }
    List <Quote> quoteList = [SELECT id, name, opportunityid FROM Quote WHERE Id IN: oppIds];
    for(Attachment attach : Trigger.new) {
        if(quoteList !=null && quoteList.size()>0){
            for(quote q : quotelist){    
                q.name = attach.name;       
            }
            insert quoteList;
        }
    }                
}

Thanks.
I have an Application object an in the Application object I have list with custom CC App records.

When CC App record is edit is executed the beforeUpdate trigger.

I'm using an algorith to calculate average responce time of the record and the calculated value is stored in a custom field of type number.

When I try to save the value

I write CCApp1.averageHours = value; //for instance value = 8.00

For some reason the value is not saved in the field of the record.

I've tried with trigger.new as explained in the following:
http://https://salesforce.stackexchange.com/questions/198273/trigger-not-updating-a-record-field

The value is saved into the field of the current CCApp record.

What I need to achieve is to store and save the value in ALL CCApp records from the CCApp recod list in the Application.

Please advise how this can be achieved?
Hi

we need all the fields (standard&Custom) names,type,length of opportunity into exel

How can we do this?

 
Hi,

Can someone help provide the testclasses for the below wrapper class?

archestain@boom.com

Class 1:


    public with sharing Class OwnerWrapper{
    public Integer Index {get;set;}
    public List<String> tcOwner {get;set;}

        public OwnerWrapper(){
        
        }
}

Class 2:


        public with sharing class AddressWrapper {
    
        public Integer Index {get;set;}
        public List<String> Addressed {get;set;}
        
     
        publicAddressWrapper(){

        }
        
    
    }
I have a reuiqrement i want to have a field in parent record and get the sum of a field from all child record. this is lookup relationship record. how to do in a easy way , please suggest me.
Hi ,
I want to create a Task counter in Opp, the counter should increase/count only if the subject is " Opp  follow-up" ( not for other subjects),  May i know how to do it ?
I was trying PB created on Task object, but couldnt able to put action that increase the " Opp Task Conter " field.
I am trying to write a trigger on Opp, If anyone can suggest , modify my below trigger which is not working to get a proper view, i am new to apex.
 
trigger TaskCount on Opportunity (before insert) {
if(newTaskList[0].WhatId != null && ((String)newTaskList[0].WhatId).substring(0,3)=='006')
        {
            opp = [SELECT Id,Name,OwnerId,Owner.Email,(SELECT Id FROM Tasks WHERE Status != 'Completed' and Subject='Opportunity follow-up) FROM Opportunity WHERE Id = :newTaskList[0].WhatId LIMIT 1];
        }
}



Any suggestions plz. Thnx
Hello
I have two custom objects , fan__c    and   subscription__c

Fan object has fields (ID, email__c)

subscription object has fields(ID,fan_ID__c,mailing_list_name)

subscription object has a lookup to fan object as  : Fan_ID__cLookup(Fan)

pls help in framing the subscription query from child to parent where child is subscription object and parent is fan object.

I want to frame a query on subscription object that will fetch the related email of fan object

pls help me out
thanks
JohnD
 
Hi,
Can anyone offer some assistance with this scenario please.
I have a trigger that should be creating one of each custom object(Project_sheet__c and Project_checklist__c) when the opportunity is saved.
Both custom objects have Opporutnity look ups. The trigger was sort of working, but unfortunately I was getting multiple records being created.
I do have workflows on the Opportunity that fire when the opportunity is saved, as well as an additional trigger that creates an asset for each OLI.
I thought the issue was as this trigger is an 'Update' as well as an 'Insert', it was causing it to re-fire.
I've attempted to add a conditional statement that if there is already a Project checklist or Project sheet associated with the Opportunity then it shouldn't create an additional record.
Unfortunately it's not working at all now.
I've highlighted the additional conditional statement in bold that appears to have stopped the trigger working at all.
Any help would be appreciated.

Current trigger:

trigger InsertProjectDocuments on Opportunity (after insert, after update) {
List<Project_sheet_2__C> projSheetToInsert = new List<Project_sheet_2__C>();
List<Project_checklist__c> projChecklistToInsert = new List <Project_checklist__c>();
   
    for(Opportunity opp : Trigger.new) {
        if (opp.IsWon && (opp.Project_sheets_21__r != null) && (opp.project_sheets_21__r != Trigger.oldMap.get(opp.id).Project_sheets_21__r) && (Trigger.oldMap.get(opp.Id).IsWon !=opp.IsWon)) {
            Project_sheet_2__c ps = new Project_sheet_2__c();
            ps.Name = 'Project sheet -' + opp.name;
            ps.PS2_Opportunity__c = opp.id;
            ps.Date_created__c = system.today();  
            ps.Version_Number__c = '1';
            projSheetToInsert.add(ps);            
        }
        if (opp.IsWon && (opp.Project_sheets_2__r != null) && (opp.project_sheets_2__r != Trigger.oldMap.get(opp.id).Project_sheets_2__r) && (Trigger.oldMap.get(opp.Id).IsWon !=opp.IsWon)) {
            Project_checklist__c pc = new Project_checklist__c();
            pc.Name = 'Checklist -' + opp.Name;
            pc.Project_opportunity__c = opp.id;
            projChecklistToInsert.add(pc);
        }
    }
    if(projSheetToInsert.size() >0){
        Database.insert(projSheetToInsert, false);
    }
    if(projChecklistToInsert.size() >0){
    Database.insert(projChecklistToInsert, false);
    }
}
 
hi,
there is an integer list of (1,2,3,4,4). I want to copy this list in another list in such a way that list should not copy the number 4 twice. It should copy in a list not in set. What would be the code ?

thanks
lalit
Hello, 

I have created a field on the Opportunity object called Latest Note. When a user adds a new note to the Opportunitues Notes section I want to copy the Body and insert it to the field "Latest Note". Can a trigger be created on the Note object to handle this?

Thanks for all your help,
Ricky 
 
Hi All,

I m trying to delete a content version record from my java code using REST api using HTTPDelete :

HttpDelete delete = new HttpDelete(baseUri+"/sobjects/ContentVersion/"+v);
where delete.getURI() = https:// xxx.my.salesforce.com/services/data/v35.0/sobjects/ContentVersion/06824000000aAqlAAE

HttpResponse  response = htttpCient.execute(delete);

but i get a status 401 on delete. This same URI works if if i delete a Account object without an issue. Can anyone please help ? I would really appriciate it!

Thank you!
I'm having trouble getting my case before insert trigger to fire when a new case is created via email to case.

I'm just wondering if that it doesnt fire for some reason when they come in via email to case?
Hi peeps,

I'm creating a trigger to update a custom object when another object is updated, inserted or deleted. The class saves fine and passes the test with 100% code coverage but when I try to update the object in salesforce i get the following error:

Apex trigger TrackOpportunityItems caused an unexpected exception, contact your administrator: TrackOpportunityItems: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Class.OpportunityItemsUpdater.addOppItems: line 29, column 1  
 
Here is the code for the class. Any help would be greatly appreciated,

Thanks :)
 
public class OpportunityItemsUpdater {

    public static void addOppItems(List<OpportunityLineItem> lineItems){
        
        List<Opportunity_Item__c> OppItems = new List<Opportunity_Item__c>();
    
        List<Id>  productIds = new List<Id>();
        for(OpportunityLineItem a : (List<OpportunityLineItem>)lineItems) {
            productIds.add(a.Product2Id);
            System.debug(productIds);
        }
        
        List<Product_Item__c> productItemsList = [SELECT Id, Quantity__c, Product__c, Item__c FROM Product_Item__c WHERE Product__c IN :productIds ];
        System.debug(productItemsList);
        
        //Map<ProductID, List<Product Items that lookup to that product>>
        Map<Id, List<Product_Item__c>> productItemMap = new Map<Id, List<Product_Item__c>>();
        for(Product_Item__c pi : productItemsList) {
            if(productItemMap.get(pi.Product__c ) == null) {
                productItemMap.put(pi.Product__c, new List<Product_Item__c>());
            }
            productItemMap.get(pi.Product__c).add(pi);
            System.debug(productItemMap);
        }
        
        
        for (OpportunityLineItem a : (List<OpportunityLineItem>)lineItems) {
            
            for(Product_Item__c pi : productItemMap.get(a.Product2Id)) {
                System.debug(productItemMap);
                Opportunity_Item__c oppItem = new Opportunity_Item__c();
                //oppItem.Opportunity_Product_Id__c = a.Product2Id;
                oppItem.Opportunity_Product_Id__c = a.Id;
                oppItem.Item_Id__c = pi.Item__c;
                oppItem.Quantity__c = a.Quantity * pi.Quantity__c;
                System.debug(pi);
                OppItems.add(oppItem);
                System.debug(oppItems);
            }
            
            
        }
        Insert OppItems;
        System.debug(OppItems);
    }
    
    public static void deleteOppItems(List<OpportunityLineItem> oldlineitems) {
        System.debug('delete');
        Set<Id> DeletedOppLineItemIds = new Set<Id>();
        for (OpportunityLineItem a :  oldlineitems) {
            DeletedOppLineItemIds.add(a.Id);
            
        }
        Delete [SELECT Id FROM Opportunity_Item__c WHERE Opportunity_Item__c.Opportunity_Product_Id__c IN : DeletedOppLineItemIds];

    }
}

 
I am not getting any error  on opportunity object and created task,but the same code is not working on contact
it giving error like this
exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Related To ID: id value of incorrect type: 0032800000NuHm0AAF: [WhatId]: T
Thanks in advance ,  Please give me solution for this 
trgger autocreatetask on Contact (after  insert , after update)  {
  
    list<task> tasklist = new list<task>();    
        for(contact con : trigger.new){
          task t = new task();
          t.whatid=con.id;
          t.Status = 'In Progress';
          t.Subject='call';
          t.Priority = 'High';
          t.ownerid= con.ownerid;

            tasklist.add(t);
        }
        
        insert tasklist ;     
    
    }
Hello,

I have a custom field for a lookup to a field. It only shows the objects that are created by me and i cannot see everything.

How can i solve it ?
Hi,

I need input on how to start with for the pop-up screen attached here.

I need to show a pop-up on a button click from an account detail page as shown in snapshot
User-added image


instead of showing any other page as pop-up, would like to create this purely in javascript/jQuery.
Thanks in advance!
I have written below trigger to update case status when case is assigned from Queue to a user, but it is giving a null pointer exception @line 10.
The requirement is to update case status when case is assigned from a queue to a user.
 
trigger updateCase on Case (before update) {
    List<Case> newCaseList = new List<Case>() ;
    System.debug('@@newCase' + newCaseList);
    for(Case c : Trigger.new) {
        System.debug('@@@' + c);
		//just add few more null checks- 
		If(c.status!=null && c.OwnerID.getsobjecttype()!=null)
		{
			if(c.OwnerID.getsobjecttype() == User.sobjecttype && c.Status == 'New') {
					if(Trigger.oldMap.get(c.Id).Owner.getsobjecttype() != User.sobjecttype) {
							c.Status = 'Working';
							newCaseList.add(c);
						}
				System.debug('@@' + newCaseList);
			}
		}
    }
    if(newCaseList.size() > 0) {
        insert newCaseList;
    }
}

 
Can someone give me some insights to what this VF code means or does? How can I find out where it is pointing to? 
<apex:page standardController="Account" extensions="FormCreateController" action="{!redirectPage}">
    
</apex:page>



Thanks!
HI All ,
We have overridden case view button to redirect to custom page/standard layout  based on record type conditiion . 
After overriding the button when console user opens mor ethen onne case either through omni channel or clicking on multiple case link scroll bar for few case layout is not working .

Please advice solution , if you have faced same problem before or any work around to solve this issue .
Thanks 
Manoj
HI All ,

I have a visualforce page ,where I am creating case .After creating case I am adding some other records as a child object to the case and  showing as a related list using <apex:relatedlist> component . Also standard attachment componenet is also there . however both records time zone is different for both ,though created by same user .

Parent records in GMT and child records in IST also format is diffrent .If any one faced this issue kindly help me .

Thanks 
Manoj
Hi All ,

I am trying to comunicate between facebook and salesforce by using the facebook toolkit .I have installed the toolkit and configure as per the below link .

https://github.com/developerforce/Force.com-Toolkit-for-Facebook

Now I am getting error (Recieved 400 from https://graph.facebook.com/me/home?access-token=null{"error":{"message":"Invalid OAuth access token",""type":"OAuthException","code":190,"fbtrace_id":DPGea\/xO92S})

Please suggest incae any one already fixed this issue .

Thanks 
Manoj
Hi All ,
In my organisation partner community is enabled ,So one profile which is the Sales Area Manager ,bacically he is a salesforce user .We have made that user as partner account owner .
When He/She loged in as asfdc user .He can use the global header to swip in to community as in community his profile is added .
Issue is I need to identify where actually he loged in whethere he is in community or Salesforce .How can I identify in apex .

 
HI All ,

I am creating a visual force email template ,in which am and using an component to use custom controller .I ahve added debug on that .However while using the template I am not able to view the debug log .Can any one suggest me .
Any suggestion is highly appreciated .

Thanks
Manoj
Hi All ,

I am working on quote ,I want to generate the quote in the form of doc file .I want to remove the header from first page only .
Any help is highly appreciated
Hi All ,
While  redering  Quote as word file ,I am facing a problem like ,Header is repeting twice in first page and footer  is repeating twice in last page .
Can nay one suggest me how to solve this issue .
Below is my code snipnet .



<apex:page sidebar="false" showChat="false" showHeader="false" contentType="application/msword#Test.doc" cache="true"> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> <style> @page Main { mso-header:h1; mso-footer:f1; } div.Main{ page:Main; } p.MyFoot, li.MyFoot, div.MyFoot{ mso-pagination:widow-orphan; tab-stops:center 216.0pt right 432.0pt; } p.MyHead { } </style> </head> <body> <div class="Main"> <div style="mso-element:header" id="h1"> <img src="https://c.cs17.content.force.com/servlet/servlet.ImageServer?id=015g000000044RX&oid=00Dg0000003MfeB&lastMod=1421154746000" style="height:10px;width:10px"/> </div> <div>Ashutosh Kumar Srivastava</div> <br style="page-break-after: always;"/> <div style="mso-element:footer" id="f1"> <img src="https://c.cs17.content.force.com/servlet/servlet.ImageServer?id=015g000000044RS&oid=00Dg0000003MfeB&lastMod=1421154652000" style="height:10px;width:10px"/> </div> </div> </body> </html> </apex:page>


Any help is heartily appreciated .
 
Hi All ,

I want  to track  location of the user, when he/she is updating event or posting status via portable devices such as smart phone or tablet.

Any solution is highly appreciated .

Thanks
Manoj
Hi All,

My code is returning a expression in string format. I need the calculated value in integer /double format.

String str = '25*5';
Integer result=Integer.valueOf(str);

Throwing error as Ivalid type exception.

Please help me on this .
I am facing an issue while uploading data in china language .It is uploading data but not in proper format .It is uploading with some spacial character .

Please help me on this .

Thanks ,
Manoj
Hi All,

I have reset auto number field in production after 2 records it is automatically jump to 33/35 like this .Can any one help me on this .

Thanks in advance.


Can any one help me on this,I am working on community need to modify the login page ?

I am following the documment but not able to complete the job.

Any suggesion is appreciated.

Hi All,

 

I want to save pdf  in to  local drive by the help of apex class.

 

Can any one suggest me how to fix this

 

Thanks in advance.

HI All,

 

I am craeting  a dynamic table in VF.In the table in each row first 2 column is generating from parent record and the rest four column is generating from child.For this I am iterating with two repeat .But the issue is , my td in table is gerating according to the size of the child record. I want every time the table should comlete whether the record is there or less in child object.

 

Can any one suggest me for this.

Thanks

Situ

 

Hi All,

 

  I need to give access to partner objcet without ViewAllData Access to a particular profile.Can any one help me on this.

 

Thanks In Advance

Situ

Hi All,

 

   I am facing a issue like in task Edit Mode I am able to view the Attach File for new Attachment in Attachment ralated List ,but not in detail mode in same record.Can any one help me on this.

 

Thanks in advance

Situ

Hi All,

 

     I have a query in that one condition  is there, like ' where  isSyncing=true' .In my test class I am not able to assign value to that isSyncing field .Can any one suggest me how to solve the issue .

 

Thanks In adavce.

Situ

Hi All,

 

 I am working on a pdf ,In the pdf  the table has a lot of records so it is creating more then 10 page .I need the table header in each page .also in the last page I don't need the header .Can any one suggest me some solution for this .

 

 

Thanks

Situ.

HI All,

 

I have declared a global variable in outer class and trying to access that varibale in inner class method it is showing error.

 

Can any one help me plz it very urgernt.

global class GlobalTest{   

    global String value='Situ';      

    public class Myclass{            

          public void  gtestMethod(){                  

               System.debug(value);     

          }

      }  

}

Error is like Variable does not exist: value at line 6 column 24

Thanks

Situ

HI All,

 

 I am calling a page reference method on click of a coomand button ,It perfectly working in all browser accept IE 9.

Please help me on this if some one has any idea try to give me solution ASAP.

 

Thanks

Situ.

I am facing an issue while uploading data in china language .It is uploading data but not in proper format .It is uploading with some spacial character .

Please help me on this .

Thanks ,
Manoj
I want to delete dupicate accounts below code for your reference. Attached is the error
global class DuplicateRecords implements Database.Batchable<SObject>  {

     

  Global Map<String , Account__c> AccountNumberBookmap = new Map<String ,  Account__c>();

     

    global Database.QueryLocator start(Database.BatchableContext BC){

      return Database.getQueryLocator([Select AccountNumber__c from Account__c where AccountNumber__c != null]);

      }

     

     

     

    global void excute(Database.BatchableContext BC , List<AccountNumber__c> scope){

         

      

         

         

      // Map<String , AccountNumber__c> AccountBookmap = new Map<String , AccountNumber__c>();

         

        List<AccountNumber__c> duplicatelist = new List<AccountNumber__c>();

        for(AccountNumber__c s : scope){

            if(! AccountBookmap.containsKey(s.Account__c)){

                AccountBookmap.put(s.Account__c , s);

            }

            else{

                duplicatelist.add(s);          

            }                       

        } 

                

        

       system.debug(duplicatelist);

        if(duplicatelist.size() > 0){

            delete duplicatelist;

        }

    }

     

    global void finish(Database.BatchableContext BC){

         

    }

         

 

}
User-added image
I tried but my code is not working
trigger AttachmentTrigger on Attachment (before insert) {
    Set<Id> attid = new Set<Id>();  
    for(Attachment att : Trigger.new){
        attid.add(att.parentId);
        
    }
    Map<Id,Account> acMap = new Map<Id,Account>([select id,(select id,parentId from attachments) from Account where Id IN : attid]);

    for(Attachment att : Trigger.New){
       
        if(acMap.get(att.parentId).attachments.size() > 4 ){
            
            att.adderror('You can not add more than 4 attachments!');
        }
    }
}

Can someone help me on this
how to make a number  field(total units__c) as a read only, non editable and that field should have default value. for example , if (total units__c) is set to a default value 10.whenever a status__c(picklist) is selected as sold,the (total units__c) should decrease by 1
  • April 30, 2019
  • Like
  • 0
Hi All,

How to write a scheduler class for daily and weekly for below Batch Apex
  • IF the recent Recharge record for 'Internet Plan' record was made 1 day ago and its 'Data Plan' = 'Daily', then create Recharge record.
  • IF the recent  Recharge for 'Internet Plan' was made 6 days ago and 'Data Plan' = 'Weekly', then create Recharge record.
    global class batchCreateRecharge implements Database.Batchable<sobject> {
      
        global Database.QueryLocator start(Database.BatchableContext bc){
          
            String query = 'SELECT Id, Data_Plan__c,Total_Amount__c FROM Internet_Plan__c';
            return Database.getQueryLocator(query);
        }
          
        global void execute(Database.BatchableContext bc, List<Internet_Plan__c> scope) {
          try {
         List<Recharge__c> rcList = new List<Recharge__c>();
            for(Internet_Plan__c IP : scope) {
               Recharge__c rc = new Recharge__c();
              rc.Amount__c = IP.Total_Amount__c;
               rc.Internet_Plan__c= IP.id;
             rcList.add(rc);
             System.debug('******Recharge list'+rcList);
            }
       insert rcList;
     }
             
                catch( DmlException e ) {
                    // HANDLES EXCEPTIONS RELATED TO DML STATEMENTS.
                    System.debug( 'QueryException:-\n' + e.getMessage() + '\nLine Number:-\n' + e.getLineNumber() );
                }
                catch( Exception e ) {
                    // HANDLES EXCEPTIONS OTHER THAN ABOVE SUCH AS NULL POINTER EXCEPTIONS OR ETC.
                    System.debug( 'QueryException:-\n' + e.getMessage() + '\nLine Number:-\n' + e.getLineNumber() );
                }
    
        } 
          
        global void finish(Database.BatchableContext bc) {
          
        }
    }

    Kindly Support and Suggest
Thanks
  • April 30, 2019
  • Like
  • 0
i Have created the handler for that in the text filed  i want the name but populated the id  following is my code

public class Populatedlookup {


    Public void updateField(List<Lead> leadList){
        /*
        for(lead l : leadList){
            leadId.add(l.Id);
            System.debug('leadid'+ leadId.add(l.Id));
        }
        lead leadOne = [select id, name, Channel_Partner__c from lead where Id IN: leadId];
        if(leadOne.Channel_Partner__c!=null){
        Distributor__c dis = [select id, name from Distributor__c where Id=:leadOne.Channel_Partner__c];
        DistributorName = dis.Name;
*/
        for(Lead leadObj:LeadList){
            if(leadObj.Channel_Partner__c!=null){
                leadObj.Channel_Partner_Text__c=leadObj.Channel_Partner__r.Name;
            }
            else{
                leadObj.Channel_Partner_Text__c='';
            }
            
        }
      
    }
}
Hi Everyone I am new in Salesforce/Beginner
My Scenario is:

If a Account record is created and custom state field(Picklist)  value is Gujarat then owner should be changed with some role in hierachy i want to check four levels for assigned a new user to existing account owner if last role is not available then user above him role hierarchy will be assigned and if above them is not availble then above him is assigned so this levels up to four level and last one by default assigned below all are not available

 
Hi All,

We have object Fee which is child of the Account object. Fee is calculated once a year per account and we need to display most recent Fee on Account level. 

Current fee is stored in Fee_Amount__c field and ti is a formula field which holds currence data type.

We need to display Fee_Amount__c value on Account level from most recently created Fee record.

Thank you in advance
Hi, 
 
 I am trying to update quoteline fields from quote using a trigger and helper class it is not getting updated I am not get getting any error please suggest me what is the issue in below code. 

Trigger
trigger QuoteTrigger on Quote (before  insert, Before Update, After Insert) {

   if(Trigger.isAfter && Trigger.isInsert){
      system.debug('After update calling...');
      QuoteTriggerUtils.updateQlineDecimals(Trigger.new); 
    } 

}
Helper Class 
public static void updateQlineDecimals(List<Quote> qList){
        List<id> QtIds = new List<id>();
        List<QuoteLineItem> Qtlinlst = new List<QuoteLineItem>();        
        for(Quote quote:qList){
            QtIds.add(quote.id);
        }       
        List<QuoteLineItem> Qtlines = [select id, Reseller_Discount__c, Disti_Discount__c from QuoteLineItem where quoteid in :QtIds];
        
        for(QuoteLineItem Qtl : Qtlines){        
          //Qtl.Disti_Discount__c = String.Valueof(Decimal.Valueof(Qtl.Disti_Discount__c).setscale(2));
          //Qtl.Reseller_Discount__c = String.Valueof(Decimal.Valueof(Qtl.Reseller_Discount__c).setscale(2));
          system.debug('Disti Discount  ' + Qtl.Disti_Discount__c);
          system.debug('Reseller Discount ' + Qtl.Reseller_Discount__c);
          Qtl.Disti_Discount__c = '1';
          Qtl.Reseller_Discount__c = '2';
          Qtlinlst.add(Qtl);
         }        
         update Qtlinlst;
    }
Thanks
Sudhir
 
  • March 22, 2018
  • Like
  • 0
when i am updating the trigger the contact description is not changing and how to write code for delete trigger for contacts in the same code.....

trigger contactbeforeinsert on Contact (before insert,before update) {
    for(contact c:trigger.new){
         if (c.Description == null)
        {
            c.Description = '(before Contact insert trigger wrote this)';
        }
        else
        {
            c.Description = c.Description + '(before Contact insert trigger wrote this)';
        } 
        for(contact con:trigger.old){
        if (trigger.isBefore) {
        if(trigger.isUpdate)
        {
        contact con1 = [select id , lastname , Description from contact];
            if(con1.Description == null){
        con1.Description = 'New description';
       
        }
             update con; 
        }
            
    }
    }
}
}
Hi Friends,

Please help on below Trigger. I am trying to insert Quote when the attachment is added to Opporunity and the file name contains PDF.

trigger oppattachment on Attachment (after insert, after update) {
    
    Set <Id> oppIds = new Set <Id>();    
    for(Attachment attach : Trigger.new) {
        if(attach.ParentId.getSobjectType() == Opportunity.SobjectType) {
            if(string.valueOf(attach.Name).contains('.pdf')) {
                oppIds.add(attach.ParentId);
            }
        }
    }
    List <Quote> quoteList = [SELECT id, name, opportunityid FROM Quote WHERE Id IN: oppIds];
    for(Attachment attach : Trigger.new) {
        if(quoteList !=null && quoteList.size()>0){
            for(quote q : quotelist){    
                q.name = attach.name;       
            }
            insert quoteList;
        }
    }                
}

Thanks.
Hi, 

  I am trying to use some logic to get all parent and all child accounts from below code Please suggest me how to change.
 
public static voidAllAccounts (Id ChildId){
     
    Set<id> allacts = ReceiveAllAccounts(ChildId); // I am trying to get all account getting too many soql 
    
    For(Account acc : [select id,name, parentid, (Select id,NSE_1__c,NSE_2__c from contacts)from account where id = :allacts]){
        
        For(Contact c : acc.contacts ){
            
            if(c.NSE_1__c == true)               
                 NSEint1 = NSEint1 +1;
                 //NSEmap1.put(acc.id,NSEint1);
                 
            
            if(c.NSE_2__c == true)
                NSEint2 = NSEint2 + 1;                          
                //NSEmap2.put(acc.id,NSEint2);              
            
        }
         NSEmap1.put(acc.id,NSEint1);
         NSEmap2.put(acc.id,NSEint2);
         
        if(acc.parentid != null)            
           childToParnet(acc.parentid);
        
     }
  }
  
  
  
public static set<id> ReceiveAllAccounts(Id PAccountid){
 
  set<id> setactid = new set<id>();
  id accountId = PAccountid;
  
  // Get All Parents 
  Account[] allparents = new Account[] {};
            
  Set<Id> parentIds = new Set<Id>{accountId};
                
  Account[] parent;
        
  do {
            
   parent = [select Id,ParentId, Name from Account where Id in :parentIds];
            
   allparents.addAll(parent);
            
   parentIds.clear();
            
   for (Account par : parent) 
                
     parentIds.add(par.ParentId);
            
    } while (parent.size() > 0);
        
  list<Account> Act = [select id, name from account where id in :allparents];
        
  for(Account A : Act){    
     system.debug('Parent Accounts ' + a.name);  
     setactid.add(a.id);
     }  
  
  
   // Get all child
    Account[] allChildren = new Account[] {};

    Set<Id> childrenIds = new Set<Id>{accountId};

    Account[] children;

    do {

    children = [select Id, Name from Account where ParentId in :childrenIds];

    allChildren.addAll(children);

    childrenIds.clear();

    for (Account child : children) 

      childrenIds.add(child.Id);

    } while (children.size() > 0);

    list<Account> Acts = [select id, name from account where id in :allChildren];

     for(Account A : Acts){
 
     system.debug('Child Accounts ' + a.name);       
      setactid.add(a.id);
     }
  
      return setactid;


}

Thanks
Sudhir
  • November 28, 2017
  • Like
  • 0
I have an Application object an in the Application object I have list with custom CC App records.

When CC App record is edit is executed the beforeUpdate trigger.

I'm using an algorith to calculate average responce time of the record and the calculated value is stored in a custom field of type number.

When I try to save the value

I write CCApp1.averageHours = value; //for instance value = 8.00

For some reason the value is not saved in the field of the record.

I've tried with trigger.new as explained in the following:
http://https://salesforce.stackexchange.com/questions/198273/trigger-not-updating-a-record-field

The value is saved into the field of the current CCApp record.

What I need to achieve is to store and save the value in ALL CCApp records from the CCApp recod list in the Application.

Please advise how this can be achieved?
Hello Everyone,

I am new to salesforce development and need help on SOQL query.

We follow account hierarchy (Parent-Child relationship) and all opportunities which we create are associated with child accounts. Need help in querying all the opportunities of the child records which I want to show on parent record.

Regards,
Rahul

 
Hi All ,

I am trying to comunicate between facebook and salesforce by using the facebook toolkit .I have installed the toolkit and configure as per the below link .

https://github.com/developerforce/Force.com-Toolkit-for-Facebook

Now I am getting error (Recieved 400 from https://graph.facebook.com/me/home?access-token=null{"error":{"message":"Invalid OAuth access token",""type":"OAuthException","code":190,"fbtrace_id":DPGea\/xO92S})

Please suggest incae any one already fixed this issue .

Thanks 
Manoj
Hi

we need all the fields (standard&Custom) names,type,length of opportunity into exel

How can we do this?

 
I have 2 objects may be a standard or custom objects, I want to know which the parent or which is child object??

 
I am having a piece of code which fetches countryname along with its code from custom setting
and populates the country name into the visual force page.

In custom setting, type=LIST , anme is Countries__c and it has a field called CountryCode__c.

if the user selects Australia from vf page and click SAVE button then 'CA' is stored in the backend and so on.
The values in custom settings are not very huge.

Now i need to have another picklsit in vf page , which will display the state name based on the country selected.

I want to store the states names also in custom settings(state names are not many just a few).

Here is what I have achieved so far.
 
public List<SelectOption> CountryCodeList=new List<SelectOption>();

public String selectedCountryCode {get; set;}

 public  List<SelectOption> getCountryCodes() 
   {
        if(countryCodeList.isEmpty())
        {
           countryCodeList=new List<SelectOption>();
           List<Countries__c> allCountries = new List<Countries__c>();

           allCountries = [SELECT  Name,CountryCode__c
                                  FROM    Countries__c];

             
          allCountries.sort();
          
List<Countries__c> cList=new List<Countries__c>([select CountryCode__c 
                                                        from Countries__c 
                                                        where CountryCode__c=:selectedCountryCode]);
          
          if (cList.size() > 0)
          {
          
            for(Countries__c country : allCountries )
            {
              
                countryCodeList.add( new SelectOption( country.CountryCode__c, country.Name ) );
            }
          }
          else
          {
             countryCodeList.add(new SelectOption('--Select--', '--Select--'));

          }
       } 
     
        return countryCodeList;
   }
   
   

<apex:selectOption itemValue=" " itemLabel="--Select--"></apex:selectOption>
<apex:selectOptions value="{!countryCodes}"></apex:selectOptions>
</apex:selectList>

Please let me know how to capture value of first picklsit and based on that get the states for that country.
also how to design the custom setting so as to include the states and how to use changes in vf page.

I request the forum members to help me out urgently.

Thanks
krishna
 
We would like to avoid to hardcode value in an apex class and use "environment variable". Is the use of custom settings the right way to do that ? 

Today I created a custom settings containing 2 fields, an url and a authorization token. The values are differents from one sandbox to another, so I create one data set for each of my sandbox (dev-int-uat-prod). Now my problem is to know in wich sandbox am I ? To retrieve the right values from my custom setting and of course I don't want to hardcode it. I used UserInfo.getUserName().substringAfterLast('@').substringAfterLast('.') to retrieve the sandbox name but for production this code doesn't work, so can anyone help me on the best way to do that ?

Thanks in advance for your answers and your help.
I am deploying my Trigger and test classes to Production but i am getting the error  too much soql queries 101....and the test classes that are already in production are failing ... and as i have checked the error lines of Test class the method of class is callling and there is no problem of anywhere of SOQL query.. please explain me what happening?
I'm trying display a field and line break only if a certain checkbox, ".Activity_Completed__c",  is unchecked, otherwise I don't want it to display anything.

<apex:outputText rendered="{!IF(OR(ISBLANK, 'cx.Activity'), !NOT(cx.Activity_Completed__c)), NULL, '{!cx.Activity__c}<br/>'}" />
<apex:outputText rendered="{!IF(OR(ISBLANK, 'cx.Activity1'), !NOT(cx.Activity_Completed1__c)), NULL, '{!cx.Activity__c}<br/>'}" />
<apex:outputText rendered="{!IF(OR(ISBLANK, 'cx.Activity2'), !NOT(cx.Activity_Completed2__c)), NULL, '{!cx.Activity__c}<br/>'}" />
<apex:outputText rendered="{!IF(OR(ISBLANK, 'cx.Activity3'), !NOT(cx.Activity_Completed3__c)), NULL, '{!cx.Activity__c}<br/>'}" />
...

I'm very new to visualforce so I'm not sure if I'm going in the right direction
I need to look for changes in a list of fields in a record using a trigger. How can I reference the list of fields and append it to the trigger.new and the trigger.old references?

Below is code I've tried to use, but my variable "s" is not recognized. Thanks for any help you can provide.
Map<Id, lda_Opportunity__c> MPPMap = new Map<Id, lda_Opportunity__c>();

list<Schema.SObjectField> FieldList = new list<Schema.SObjectField>();
FieldList.add(lda_Opportunity__c.Location__c); // Many more fields to add
        
for (integer i=0; i < trigger.new.size(); i++){
   for (Schema.SObjectField s : FieldList){
      if (trigger.new[i].s != trigger.old[i].s){
         MPPMap.put(trigger.new[i].Id, trigger.new[i]);
      }
   }
}

 
We are looking for a Salesforce Admin/PM with non-profit experience for a client in Maryland.  Long term, on-site contract opportunity.  Please email phil@tech2resources.com if interested.

Not really a question, but  solution I thought might be helpful to others:

 

Due to the nature of most backoffice (and frontoffice, for that matter) systems, the standard Address object in salesforce does not work well with integrations, especially if you are using Salesforce.com as the system of record for some addresses.  Most of these systems use a dedicated field for each address line.   We need our street address field to fit into our accounting system limitations, which are:

1. Maxium of 30 characters per line

2. No more than two lines

 

Anyway, the answer for me was some fairly basic Regex for the BillingStreet Field:

NOT(
OR(
REGEX(
BillingStreet,
".{0,30}"
),
REGEX(
BillingStreet,
".{0,30}\r\n.{0,30}"
)
)
)

My regex logic:

Must be:
Empty or Single line less than 31 characters:
.{0,30}
Two lines with less than 31 characters each line:
.{0,30}\r\n.{0,30}

You can also do this with negative enforcement, but the positive model is much cleaner (example shown with 60 character limit instead of 30):

NOT:
2 or more CRLFs
(.*\r\n){2,}.*
More than 60 characters on single line
.{61,}
More than 60 characters on first line of two
.{61,}\r\n.*
More than 60 characters on second line of two
.*\r\n.{61,}

I learned the following about SF regex while doing this:

1. It does not appear to operate in multi-line mode (IE the $ zero-width match does not match the end of each line, just the end of the field)

2. The dot (.) does not match EOL characters (\r and \n)

3. Your regex has to match the entire field - all lines to be true.   In other workds, .* will not match a multi-line field.

4. To match the entire field regardless of the number of lines you would use (.*\r\n){*}

5. SF Address field uses \r\n as their EOL for the purposes of regex (I think this is different than the export, which is supposed to use just \n).

 

Enjoy,

 

Brandy Peterson