• shruthi
  • NEWBIE
  • 323 Points
  • Member since 2011

  • Chatter
    Feed
  • 11
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 63
    Replies

I am working on Q1 commissions and I see that Reps can go back and change the amount of opportunity after they have closed the opportunity. Can you please change the settings so that only I can do that and no reps after opportunity is closed? This is really urgent as it is messing up my commission calculations.

 

Suzie Squiers 703-509-2825

Hi,

 

Can u plz give the solution to the following questions.

 

1. Can we insert multiple Knowledge articles at a time using either salesforce customization or coding from system log or from apex class?

 

2. If it is possible list of articles insertion at a time, then how can i relate these articles to a particular case? While inserting any article from system log it shows all fields which are in article is not writable? so as per my understanding, its not possible to insert bulk articles or a single article from any apex code? is my understading correct?

 

3. To relate the articles to a case, i went through case related list -> articles section -> clicked on new button -> then i chosen an article type .................then i created a new article. Now this article created from case related list  is related to that particular case. But while going with any dataloader or any list insertion from code how can we related all the list of articles to case? here i can able to see  sourceid field on article, but its not useful to enter case id. Because all fields which are from articles object are not writable.? 

 

 

Please give your valuable reply.

 

 

 

Hi All,

 

trigger CountArchivedSCsonSA on ServiceContract (before update) {

     Set<Id> esIds=new Set<Id>();
     for (ServiceContract es : trigger.new)
     {
        esIds.add(es.Service_Agreement__c);
     }

     List<Service_Agreement__c> sis=[select id, DEBUG_HasArchivedSC_Indicator__c, (select id from service_contracts__r) from Service_Agreement__c where id in :esIds];
    
     for(Service_Agreement__c si : sis) {
      
      si.DEBUG_HasArchivedSC_Indicator__c  = si.service_contracts__r.size();
      si.Stage__c = si.service_contracts__r.Stage__c
  }
  update sis;
}

 The above trigger is quite simple - provides a count of records on a related list and updates a field (DEBUG_HasArchivedSC_Indicator__c) on the parent object.

 

However , when i add  si.Stage__c = si.service_contracts__r.Stage__c it dosnt work - i get : 

 

Save error: Invalid foreign key relationship: Service_Agreement__c.service_contracts__r

 

Dont quite understand why - as i am not doing anything different from the line above it, part from Instead of counting the records, I want to pass the value of the a field on one of the records back to the parent object. NB. Their will only ever be 1 record of type Service_Contract__c

 

Thanks in advance for your help.

 

Steve 

I have a trigger which will update the number of contacts on an account.

 

It is giving a problem when i am trying to update 800 records with dataloader out of which 600 got updated and gives me an exceptionlike this:

Apex script unhandled trigger exception by user/organization: 00xxx/00xxx

 contactCount: System.LimitException: Too many script statements: 200001

 

How do i solve this problem,is it a bulk trigger or do we need to change anything in the code. Pls send me the right code to handle this.

I appreciate any help on this

 

Here is the code of the trigger,
 

trigger contactCount on Contact (after insert, after update, after delete, after undelete) {

   Contact[] con;
    
    if (Trigger.isDelete) {
        con = Trigger.old;
    }
    else { 
        con = Trigger.new;
    }
    
    Set<ID> accIds = new Set<ID>();
    
    if (Trigger.isUpdate){
        for(Contact c: Trigger.old){
            if(c.AccountId != null) {
                accIds.add(c.AccountId);
            }
        }
    }
    
    for (Contact c : con) {
        accIds.add(c.AccountId);
    }
    
    Map<ID, Contact> conmap = new Map<ID, Contact>([select Id, AccountId from Contact where AccountId in :accIds And AccountId != null]);
    Map<ID, Account> accmap = new Map<ID, Account>([select Id, Number_of_Contacts__c from Account where Id in :accIds]);

    for (Account a : accmap.values()) {
        
        Set<ID> conIds = new Set<ID>();
        
        for (Contact c : conmap.values()) {
            if (c.AccountId == a.Id) {
                conIds.add(c.Id);
            }          
        }
        if (a.Number_of_Contacts__c != conIds.size()) {
            a.Number_of_Contacts__c = conIds.size();
        }      
    }   
    update accmap.values();
}

I'm honestly starting to wonder whether I will EVER get this .... here's what I'm trying to do:

 

1./  Ask user for Account Name on page 1 of wizard

2./  Display account name chosen AS WELL AS value of custom field on that account record on page 2 of wizard.

3./  Ask user for Request Type, Category and Action on page 2 of wizard.  The picklist options in the Request Type, Category and Action fields will be based on  the value of the custom field (Global Region) in the account record.

 

I am COMPLETELY FRUSTRATED and lost in trying to get this to work.  It just seems like it should be SOOO simple ... although I'm new to Apex, I know other programming languages ... why is this so difficult to grasp?

 

If anyone can help, I would be forever grateful.   And please ... give me notes and reasons why I'm doing things ... others have tried to help by just giving me links to other wizards, but because those wizards aren't doing what I want to do, they don't help me understand how to build mine.

 

Thanks ...

 

Current Custom Controller Code

public class ARWizard {

    public ApexPages.standardController controller {get; set;}
    
             
    public Assistance_Request__c assistanceRequest { get; set; }
     
    public Account account {get;set;}
    
    public ID accountID {get;set;}
    
    public ARWizard (ApexPages.standardController controller) {
        //Added by Lokesh
        if(assistanceRequest ==null)
             assistanceRequest =  new Assistance_Request__c();
      
  }   
  

    public PageReference step1() {
        return Page.arStep1;
    }

     public PageReference step2() {

      
        try {
            account = [SELECT Id,Name,Global_Region__c
                       FROM Account
                       WHERE Id =: AssistanceRequest.Account_Name__c];
                      
           }
        catch(Exception e)  {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage()));
    }
    return Page.arStep2;
     }


       public PageReference save() {
                System.debug('&&&&&&& Account=' + account);
            try{
                insert assistanceRequest;
            } catch (System.DmlException e) {
                ApexPages.addMessages(e);
                return null;
            }
            controller = new ApexPages.standardController(assistanceRequest);
            return controller.view();
        }
}

 

Current Page 1 Code:

<apex:page standardController="Assistance_Request__c" extensions="ARWizard" tabStyle="Assistance_Request__c">
  
    <script>
    function confirmCancel(){
    var isCancel = confirm("Are you sure you wish to cancel and exit this Assistance Request?");
    if (isCancel) return true;
    return false;
    }
    </script>
    
    <apex:sectionHeader title="Assistance Request" subtitle="Step 1 of X"/>
  <apex:form > 
      <apex:pageBlock id="theBlock" title="Assistance Request Creation" mode="edit">
          <apex:pageBlockButtons >
              <apex:commandButton action="{!step2}" value="Next"/>
              <apex:commandButton action="{!cancel}" value="Cancel" onclick="return confirmCancel()" immediate="true" style="margin-left: 2em"/>
          </apex:pageBlockButtons>
          <apex:pageBlockSection title="Account Information" columns="1">
              <apex:inputField value="{!AssistanceRequest.Account_Name__c}"/>
          </apex:pageBlockSection>
      </apex:pageBlock> 
  </apex:form>
</apex:page>

 Current Page 2 Code:

<apex:page standardController="Assistance_Request__c" extensions="ARWizard" tabStyle="Assistance_Request__c">
  
        <script>
    function confirmCancel(){
    var isCancel = confirm("Are you sure you wish to cancel and exit this Assistance Request?");
    if (isCancel) return true;
    return false;
    }
    </script>
    
    <apex:sectionHeader title="Assistance Request" subtitle="Step 2 of X"/>
    
  <apex:form > 
      <apex:pageBlock id="theBlock" title="Assistance Request Creation - Request Details" mode="edit">
          <apex:pageBlockButtons >
              <apex:commandButton action="{!step1}" value="Previous"/>
              <apex:commandButton action="{!cancel}" value="Cancel" onclick="return confirmCancel()" immediate="true" style="margin-left: 2em"/>
          </apex:pageBlockButtons>
          <apex:pageBlockSection title="Account Information" columns="2">
              <apex:outputField value="{!AssistanceRequest.Account_Name__c}"/>
              <apex:outputField value="{!AssistanceRequest__r.Account.Global_Region__c}"/>
          </apex:pageBlockSection>
          
           <apex:pageBlockSection title="Request Information" columns="2">
              This is where the request product, category and action will go.
          </apex:pageBlockSection>
      </apex:pageBlock> 
  </apex:form>
</apex:page>

 

I am pretty new to salesforce and I am struggling to create a validation rule.  I want to use the ISCHANGED function with a phone or fax number.  So if the phone or fax number is changed on an account then it triggers a field update on a custom object.  The workflow keeps telling me that I cannot use ISCHANGED with a phone or fax number.  Does anyone have a work around?  Thanks for the help.

 

Bladen

How to compare two lists in your trigger and update one of them so that you can do a single update. My trigger now has two update statements on Account object as below:

    if(!OppAccts.isEmpty()){update(OppAccts);}
    if(!CCPAccts.isEmpty()){update(CCPAccts);}

The reason for two different list is due to differeing criteria and logic that need to occur after update.

Any idea?



Hi

 

I'm trying to get a workflow rule to work but am having some trouble with my rule criteria.

 

I'm trying to send an email alert when the below criteria is met.

 

budget  >= $10,000.

flight days <= 5 days

 

Tried this but it's not working: 

AND((End_Date__c - Start_Date__c) <= 5, ( UnitPrice >= 10000))

 

Any help would be appreciated. Thank you.

Hi, if you open a standard page there is a related list called notes & attachments.

I want to show it on a visualforce page and cannot find out how anywhere in the documentation. 

I am a very new developer learning as I go. Could someone please help.

Sorry it is probably very easy but so much documentation and over 2hrs searching with no results!!

 

Thanks

 

Steve

I am trying to update a custom field on an OpportunityLine using an APEX trigger.  I am receiving an error message stating that the record is Read Only.  The sharing settings on the Opportunity are Public Read/Write.  Don't quite understand why the record is Read Only.  Any ideas?  The code in the Trigger follows.

 

trigger AddAssetTagOnOpportunityProduct on OpportunityLineItem (after insert) {

    if(Trigger.isInsert ){ 
    
        for(OpportunityLineItem lineItem : Trigger.new){
        
            String wppItemNumber = lineItem.WPP_Item_Number__c;
            
            System.debug('WPP Item Number : ' + wppItemNumber);
            
            sm1e__smEquipment__c maintenanceAsset = [SELECT Id, Name FROM sm1e__smEquipment__c WHERE
                                                     sm1e__External_Asset_ID__c = :wppItemNumber];
                                                     
            System.debug('Asset Tag : ' + maintenanceAsset.Name);
            
            lineItem.Asset_Tag__c =  maintenanceAsset.Id;
            
            update lineItem;
       
        }
    }

Hi,

 

Can i use multiple controller class in a single VF page. My Vf page dont have standardcontroller , i want to use only two or more user defined controller class. Is it possible, please let me know about its syntax or solutions.

 

 

 

I have a field called Activity_Type__c which I want to be populated based on the value of Status__c in other custom object.

Eg: IF Status__c = 'Submitted' , Activity__c = 'Submitted'. Like wise based on the Status__c value, there are 6 different Activity__c values.

 

I can do this through work flow, but that would mean creating 6 workflows for Field Update when each condition is satisfied.  I want to do this through Trigger but need help. 

 

Can somone please help me get started? Thanks in advance.

Hi,

I'm looking for a formula that's adds business days only, I.e Friday + 3 business days = Tuesday

Any help appreciated.

I have a very basic Visualforce page that displays multiple Pagemessages at the top of the page if certain fields are not filled out.  The Visualforce page is overriding the View mode of the Opportunity.  The Pagemessages update correctly when a user clicks Edit and updates the null field values.  However, when a user uses inline editing to update one of the fields and clicks Save, the Pagemessage(s) stay displayed.  How can I make it so that the Pagemessages update after someone edits the Opportunity using inline editing?  If a user updates one of the two fields with inline editing then I would like the messages to go away after the record is saved.  My code is below.

 

<apex:page standardController="Opportunity" >
    
    <apex:pagemessage summary="Number of Eligible Retirees is null." severity="warning" strength="1" rendered="{!Opportunity.Number_of_Eligible_Retirees__c==null}" />
    <apex:pagemessage summary="Current Rates is null." severity="warning" strength="1" rendered="{!Opportunity.Current_Rates__c==null}" />
    
    <apex:detail inlineEdit="true" rerender="{!Opportunity.id}" />
    
</apex:page>

Hi All,

 

I need to call two functions and want a delay of 10 seconds between then.

 

It is possible with Apex code ?

 

Thanks,

Deepak

This may seem a simple question but I would like to make a custom page layout on a custom object that has more than two columns and would like to have the fields show up in edit and view mode.

 

I assume this is done with visual force pages but are there any examples I can use to get me started?

Hi,

 

      I want to implement search functionality in my pages. where as, i have five fields.. In that,one field is Keywords:

 

     Now, i want to compare the values of keywords with the values of object and i need to populate the matched data.

 

     I split the string of keywords into into a array.

 

     For this string comparison , while using like operator, the query returns null even though i gave exact matched data.

 

     so, is there any way to compare the strings.

 

 

Regards,

Phanikumar