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

  • Chatter
    Feed
  • 193
    Best Answers
  • 1
    Likes Received
  • 6
    Likes Given
  • 23
    Questions
  • 1468
    Replies
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!
  • February 04, 2016
  • Like
  • 0
Hello,

I have a Code like below
 
List<CustomObject1__c> XYZList = new List<CustomObject1__c>();
        
	for(Account c:[SELECT Name, OwnerId, Description, Industry, Type, Website
			FROM Account limit 9999]){
                CustomObject1__c XYZ = new CustomObject1__c();
		
		XYZ.Target_Account_Id__c = c.id;
		
		XYZ.Name = c.Name;
                XYZ.OwnerId = c.OwnerId;

		XYZ.Description__c = c.Description;
                XYZ.Industry__c = c.Industry;
		XYZ.Type__c = c.Type;
		XYZ.Website__c = c.Website;

                
		XYZList.add(XYZ);
         }

        if(XYZList.size()>0){
            insert XYZList;
        }
This gives me below error.

I have added below lines at top of code but in vain
 
Profile objProfile = [Select Id, Name from Profile where Name =: 'System Administrator' limit 1];

	User objeUser = [Select Id, ProfileId from User where Id=: UserInfo.getUserId()];

Line: 38, Column: 1
System.DmlException: Insert failed. First exception on row 71; first error: INACTIVE_OWNER_OR_USER, operation performed with inactive user [005b0000000YntB] as owner of 01I8E0000008ks3: []


If i activate the user, it is running Ok, but this is not the solution i seek.

Thank you for suggestions
 
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.

Hi All,

 

I want to add the Email to case routing address to my gmail but I am not getting th everification  code which send to the routing address can any one help me on this to find the verification code ,Like in email to case routing address when the verification code is sent to the address it is automatically created on case in salesforce.Like this is there any record is created in salesforce while  sending the verification code .

 

 

Please help me on this.

 

Thanks

Samu

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, 
 
 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
 
Hi,
I have one field 'total no. of contacts' on account detail page.I want to update that no. whenever contact is deleted.
What will be the the trigger code for the same. 
Kindly help.

Regards.
The apex trigger was created a few years back and it currently updates the contact owner when the account owner is updated. It is no longer valid. Can I have some steps to action please? 
I have a picklist defined in vf page and I have created a custom setting (Countries__c ) which has a field CountryCode__c .
so its like this
Australia  CA
India        IN
America   USA

when the visual force page loads I want the picklist values to be sorted but it is not happening.
public class someclass
{
private List<SelectOption> countryCodeList = new List<SelectOption>();


    //Holds the Country Code for the selected option

    public String selectedCountryCode {get; set;}

   }

public  List<SelectOption> getCountryCodes() 
   {
        if(countryCodeList.isEmpty())
        {
           
          for(Countries__c country :Countries__c.getAll().values())
          {

            countryCodeList.add(new SelectOption(country.CountryCode__c, country.Name));
          }

        }

        countryCodeList.sort();  //doesnt work
        return countryCodeList;
   }
Please help me out.

Thanks
John
 
I have two custom objects fan and preferences.
IN fan object I have email,birthdate field and in preference sobject I have a multi select picklist wihich has a default value as ''ALTERNATIVE / INDIE'.

Preference object has a lookup to Fan object.

The email field(mandatory) is masked with asterisk, so when the page loads the code masks the contents and when the user clicks save button page is refreshed and email field value is masked.

Also when the page loads I  append an ID to the url to fetch the values.
Here is a piece of code .
public class PrefCenterCtrl{
      
    public String fanDOB { get; set; }
    public String fanCountry_Region { get; set; }
    public String fanEmail { get; set; } 
    public String fan_email{get;set;}  

     public String encryptedfanID{get;set;}
    
    public String mid{get;set;}
    
    public fan__c fan{get;set;}
      
    public Preference__c pref;
    public boolean Genre_Alternative_Indie { set; get; }

    private List<SelectOption> countryCodeList = new List<SelectOption>();

     public PrefCenterCTRL()
    {
        encryptedfanID='';
        mid='';
        
        encryptedfanID=ApexPages.currentpage().getparameters().get('id');
               
        if(String.isBlank(encryptedfanID))
        {
                ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Invalid Id.');
                ApexPages.addMessage(myMsg);
                return;
        }
        else
        {
          try
          {
            fetchfanvalues();
          }
          catch(System.QueryException ex){
                
              Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, 'No Record'));
          }
   
        }}
       
 public void fetchfanvalues()
    {
         fan = new fan__c();
         
         fan=[SELECT id, Email__c,Birthdate__c,Country_Region__c
              FROM fan__c 
              WHERE Encrypted_ID__c=:encryptedfanID];
         
         if (fan != NULL)
         {
                        
             fan_email=fan.Email__c;
             
             if(fan_email != null && fan_email != '' )
             {
                fanEmail=maskEmail(fan_email);
             }
             else
             {
                 fan_Email = fan.Email__c;
             }}

          pref=new Preference__c();
        
       try
       {
        pref = [SELECT Preferred_Genre__c
                      FROM Preference__c
                      WHERE Fan_Id__c = :fan.Id];
    //Preferred_Genre__c is defined as Multiselect Picklist in Preference object   
    String Pref_Genre = pref.Preferred_Genre__c;  
       
       if(Pref_Genre != null)
       {
             string[] Genres = pref_Genre.split(';');
                    
             for(integer G=0; G<=Genres.size()-1; G++)
             {
                            
                            if(Genres[G] == 'ALTERNATIVE / INDIE')
                                Genre_Alternative_Indie = true;
            }

        }               
           
        catch(system.Exception ex)
        {
          
        }
     }

//code to mask the email with asterisk when the page loads and also when the user clicks save button the email field content is masked with asterisk
  private String maskEmail(String sEmail)
    {   String sMaskedEmail;      
        String[] aEmail = sEmail.split('@');   
        if(aEmail.size() == 2)
        {      
          sMaskedEmail = aEmail[0].left(1); 
          for(integer i=0; i < aEmail[0].length() - 1; i++)
          {
            sMaskedEmail += '*';
          }      
          String[] aEmail2 = aEmail[1].split('\\.', 2); 
          sMaskedEmail += '@' + aEmail2[0].left(1);  
          for(integer i=0; i < aEmail2[0].length() - 1; i++)
          { 
            sMaskedEmail += '*';
          }   
          sMaskedEmail += '.' + aEmail2[1];  
        } 
          return sMaskedEmail; 
    }

//The country along with its codes is stored in custom setting
  public  List<SelectOption> getCountryCodes() 
   {
        if(countryCodeList.isEmpty())
        {
           
          for(Countries__c country :Countries__c.getAll().values())
          {

            countryCodeList.add(new SelectOption(country.CountryCode__c, country.Name));
          }

        }

        countryCodeList.sort();
        return countryCodeList;
   }

public void LoadMaskedValues()
   {
       fan = new fan__c();
       
       if (fan != NULL)
       {
      
           fan=[SELECT id, Email__c,Mobile_Phone__c
                       FROM fan__c 
                       WHERE Encrypted_ID__c=:encryptedfanID];
                       
           if(!string.isBlank(fan.Email__c))
           {
                fan_email=fan.Email__c;
                fanEmail=maskEmail(fan.Email__c);
           }
}
 
 public void SaveValues()
 {
     if (fan != NULL)
      {
      
      if(!fanEmail.contains('*'))
      {     
            integer count = [SELECT Count() FROM Fan__c WHERE Email__c =:fanEmail];
            if(count > 0)
            {
                Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, 'This Fan Already Exists In The System'));
                return;
            }
             else if(string.isEmpty(fanEmail))
            {
               ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'Email Cannot Be Blank')); 
               return;
            
            }
            else if(!Pattern.matches('([a-zA-Z0-9_\\-\\.]+)@((\\[a-z]{1,3}\\.[a-z]{1,3}\\.[a-z]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})', fanEmail))
            {
              ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'Invalid Email')); 
              return;
            }
            else
            {
              fan.Email__c = fanEmail;
            }
       }
      if(!string.isBlank(fanDOB))
      {
       fan.Birthdate__c=Date.parse(fanDOB); 
      }

   try
      {
         upsert fan;
      }
      catch(System.DmlException ex)
      {
            
        Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, 'Cannot Update the Record.'+ex.getMessage()));
      }
     }   
     
     LoadMaskedValues();         
}    

public void SavePreferences()
    {    
    
    if (pref != NULL)
    {
        string Preferred_Genre = '';
        
        if(Genre_Alternative_Indie == true){
            
            Preferred_Genre += 'ALTERNATIVE / INDIE ;';
        }      

       try{
            
                pref.Preferred_Genre__c = Preferred_Genre;
                pref.fan_id__c = fan.Id;
                
                upsert pref;
                    
        }catch(System.DMLException ex){
            
            Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, ex.getMessage()));
        }
      }}

 public PageReference btn_profile_saveChanges()
    {
        SaveValues();
        return null;
    }
    
    
    public void btn_preferences_saveChanges()
    {
      SavePreferences();    
    }

Please help me in writing a test class with 100% code coverage.

Thanks
John
Hi Experts,

We have a Custom Object on Which we have reached the Maximum Lookup Fields Limit 40. Now in order to accomadate new Lookup Fields
we want to remove some of the existing Lookup fields. 

What factors should be taken to consideration in order to remove, some of the existing Lookup fields like for eg if there is no data populated for a Lookup field and not reference any where in the code we can delete such Lookup Fields,can you  give some more scenarios where
we can delete lookup fields.

Thanks.
Hallo everyone,
 I have 2  custObject 
1. Spesen
2. Spesenabre 
when a User makes a  new record  or records in Spesen , i would like to show  this records in another Object (spesenabre) depend on month and User.
like  User :xx       Month :Feb 
so if a person choose  xxx and feb 
i would like to see trhe records belongs to this user  in Feb 
any help please ?
 I want to create a custom button in my opportunity object that can do very specific tasks. It needs to delete the opportunity clone, uncheck the Opportunity rolled checkbox and change the stage from closed to actively selling. Any ideas on where to start with this one?
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