• faceroy123
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 20
    Replies

Hi,

 

I have the page below, which upon 'save & edit' I want to display the accountid lookup field.


At the moment the lookup field is not displaying when I rerender the page using the quick save (save & edit) button in the page.

 

Also, is there a way to show this field only if the string of the account number begins with '700'?


i.e. the accountid only needs to show if the account number starts with '700'.

 

Thanks

 

<apex:page standardController="Case">
        <apex:form >
            <apex:pageBlock title="Rich Contact Details">
                <apex:pageBlockButtons location="bottom">
                    <apex:commandButton action="{!QuickSave}" value="Save & Edit" rerender="theFields,theCode" oncomplete="RefreshText();"/>
                    <apex:commandButton action="{!Save}" value="Save & Close"/>
                </apex:pageBlockButtons>

                <apex:outputPanel layout="none" id="theFields">
                    <apex:pageMessages />
                    <apex:pageBlockSection >
                        <apex:inputField value="{!Case.subject}"/>
                        <apex:inputField value="{!Case.casenumber}"/>
                    </apex:pageBlockSection>
                </apex:outputPanel>
      

<apex:outputPanel layout="none" id="theCode" > 
 <apex:inputField value="{!case.accountid}" required="true"  rendered="{!if(case.Account_Number__c!=null, TRUE, FALSE)}">
           </apex:inputField>    </apex:outputPanel>     
                <apex:pageBlockSection columns="1">
                    <apex:inputField value="{!Case.Account_Number__c}"/>
                    
                          
                </apex:pageBlockSection>
            </apex:pageBlock>
        </apex:form>
    </apex:page>
                      

 

Hi,

 

I need to render 2 different fields based on the input in a text field.


I can work out how to diplay fields / sections based on a checkbox but is this doable based on text input?

Here's my page code so far (which doesn't work).

I want to render the account id lookup if the account number begins with '700'

 

Any help appreciated.

 

<apex:page standardController="Case">
<apex:form >
<apex:sectionHeader title="Case" subtitle="{!Case.CaseNumber}"/>
<apex:pageBlock title="Case">
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!Save}"/>
<apex:commandButton value="Cancel" action="{!Cancel}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="New Section" columns="2"><apex:inputField value="{!Case.Account_Number__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection id="theBlock">
   <apex:inputfield value="{!case.Account_Number__c}">
      <apex:actionSupport event="onchange" rerender="theBlock"/>
   </apex:inputfield>

   <apex:inputText value="{!case.accountid}" disabled="false" rendered="{(String)case.account_number__c).substring(0,3) == '700')}"/>
   <apex:inputText value="{!case.accountid}" disabled="true" rendered="{(String)case.account_number__c).substring(0,3) == '700')}"/>

 

Hi,

 

would anyone be able to assist me in writing a test class for a regex trigger:

 

It searches the subject field on a case and updates a field if it finds a match.

 

Thanks

 

rigger Case_ConsNumber1 on Case (before update) {
    
    for(Case c:Trigger.new)
      if(c.subject!=null && c.Tracking_Job_Number__c == null) {  
string subject = c.subject;
Pattern p = Pattern.compile('[A-Z]{2}\\d{6}|[a-z]{2}\\d{6}]|[A-Z]{3}\\d{5}|[a-z]{3}\\d{5}]');
Matcher m = p.matcher(c.subject);

if (m.find()) 
{
 if (c.origin=='Email'){
  c.Tracking_Job_Number__c=(m.group(0));
 


}}}}

 

Hi,

 

Im getting the error message when I update a case record:

 

Error: Invalid Data.

Review all error messages below to correct your data.
Apex trigger Case_CopyConsignmentNumber caused an unexpected exception, contact your administrator: Case_CopyConsignmentNumber: execution of BeforeInsert caused by: System.NullPointerException: Script-thrown exception: (System Code)

 

I'm trying to search the description field for a unique text string (2 letters followed by 6 letters) and populate the Tracking_job_number__c field with this unique string if this is found.

 

 

trigger Case_CopyConsignmentNumber on Case (before delete, before insert) {
    
    for(Case c:Trigger.new){
        if(c.Description!= null && c.Tracking_Job_Number__c == null){
            // First, instantiate a new Pattern object
            Pattern MyPattern = Pattern.compile('[A-Z]{2}\\d{6}|[a-z]{2}\\d{6}]');
            //return a string that contains only numeric values from 0-9 from my original input
            String ConsignmentNumber = MyPattern.matcher(c.Tracking_Job_Number__c).replaceAll('');
            
            if(ConsignmentNumber!=null){
                System.debug('>> found'+ConsignmentNumber);
                c.Tracking_Job_Number__c=ConsignmentNumber;
            }
        }
    }}

 

Hi,

 

We are using SFDC email to case.

Is there a way to search a text area (body of the email) for a unique number and populate this to a field within the case object?

 

The unique number always follows this format e.g FY554077

(2 letters followed by 6 numbers).

 

Many thanks

 

 

Hi,

 

I have a custom process for converting leads in our org.

I have added some more fields to this to map over to opportunities that are created upon conversion.

 

However upon testing the class i'm getting this error: System.NullPointerException: Attempt to de-reference a null object

"Class.CustomLeadConverterController.<init>: line 81, column 1
Class.CustomLeadConverterControllerTest.myUnitTest: line 81, column 1"

 

 

Here is the test:

 

 

I need to deploy these changes but unsure what that message means and what I need to amend in order to fix.

 

Thanks

trigger volumes on case (before Insert, before Update) {
        for(case x : Trigger.New){        
                     

       if (x.region__c == 'South West'){   
           x.consignments_volumes__c = Volumes__c.getinstance('1. January 2012 SW').Id__c; 

       if (x.region__c == 'North West'){   
           x.consignments_volumes__c = Volumes__c.getinstance('2. February 2012').Id__c;
                            
} 
   }}}

Hi, relatively new to this so I appreciate any help!

 

Can anyone advise why this trigger does not work? it's referencing a custom setting.

 

If I remove the 'if' line, then it seems to work. Any ideas?

 

Thank you

 

 

Hi,

 

I have this trigger. I want to expand, so that upon insert or update a case will automatically populate a lookup field to a custom object:

trigger volumes on case (before Insert, before Update) {
        for(case x : Trigger.New){        
        if (x.region__c == 'south west' & x.financial_period__c == '1. January 2012'){   
       x.Cons__c = 'a0iM0000001cI6F';                                     
} 
   }

 How can i avoid hard coding the record ids, so that when I deploy to another environment the trigger will work?

 I understand I could use custom settings but I have never used these before.

 

Thanks

 

 

 

 

Hi,

 

Is the following possible?

 

I have create a new custom object (let's call it custom__c).

This holds records that I want a case to be related to, if the case meets a certain criteria. I want to automatically populate the look up field on the case. Is this possible? and how would I do this without hardcoding the record id's?

 

e.g

 

if case_region__c = 'x'

& case__date__c = 'y'

custom__r /custom__c = record id of parent record to relate.

 

Many thanks, as always.

 

 

Hi,

 

I have a trigger that send an email when a checkbox is set to true on a task. The check box is set to true via a time based workflow.

However where 2 or 3 tasks are updated at the same time the email trigger is failing with this error message:

 

System.Que​ryExceptio​n: List has more than 1 row for assignment to SObject Trigger.Wo​rkflowEmai​l: line 5, column 1

 

Any ideas how I modify to handle more than 1 record at a time?

 

Thanks

 

 

 

Hi,

 

I have a trigger that sends an email once a field is updated (by a time based workflow).

Problem I have is that as time based workflows are processed in batches, this is only able to handle one update.

 

I guess I need to bulkify this trigger?! if so, how do I do that to the snippet below?

 

Thanks

 

trigger WorkflowEmailFromOwner on Task (before update) { 
                  
                if (trigger.new[0].escalated__c ==True && trigger.new[0].RecordTypeID =='012M00000008bZY' && trigger.new[0].number_of_updates__c ==0 ||(trigger.new[0].number_of_updates__c ==1)){
                Task tas = [select id, t.Owner.Email, t.initial_assigned_to__c, t.title__c, t.description, t.subject, t.consignment_number__c, t.Owner.Name, t.whatid, t.number_of_updates__c  from Task t where id = :trigger.new];
                       try{ 
                messaging.Singleemailmessage mail=new 
messaging.Singleemailmessage(); 
      //Save the Email in Activity History 
      mail.setSaveAsActivity(false); 

 

Hi,

 

I have managed to get a button onto the record edit page via a hack using 'home page components'. (see below)

Currently, this opens an external page.

 

I need this button to validate a field (e.g. Checkbox__c = true) and then alert the user if the checkbox is ticked or not.

Does anyone know how I'd achieve that?

 

<script type="text/javascript">
var url = window.location.href;
window.onload = function () {
if(url.indexOf('/500')!=-1 && url.indexOf('/e')!=-1) 	
	document.getElementById('topButtonRow').innerHTML = 
					document.getElementById('topButtonRow').innerHTML + 
					'<a class="btn" style="padding: 4px 3px;margin: 0 2px;text-decoration: none;" target="_blank" href="http://www.google.com">Google.com</a>';
}
</script>

 

 I want to stay away from VF as there are multiple record types etc.

 

Thanks :-)

 

Hi there,

 

In short, I need a custom button (in edit mode). to validate one field.

I have managed to get a button onto the record edit page via a hack using 'home page components'.

(http://boards.developerforce.com/t5/General-Development/How-to-add-button-on-edit-page-without-overriding-with/td-p/327153)

 

I want to stay away from VF as there are multiple record types etc.

 

However I don't know how to get this button to validate a field on the record.

 

can anyone suggest how i'd modify this? At the moment it just opens Google.com.

 

•<script type="text/javascript">
var url = window.location.href;
window.onload = function () {
if(url.indexOf('/500')!=-1 && url.indexOf('/e')!=-1) 	
	document.getElementById('topButtonRow').innerHTML = 
					document.getElementById('topButtonRow').innerHTML + 
					'<a class="btn" style="padding: 4px 3px;margin: 0 2px;text-decoration: none;" target="_blank" href="http://www.google.com">Google.com</a>';
}
</script>

 

 

Thanks

Hi,

 

I have the following code that I would like to populate a date / time field to 2 hours after task creation date (in business hours).

 

This works fine if i set this to after or before update. but i need it to work upon insert of a new task.

currently it fires this error:

 

"Review all error messages below to correct your data.
Apex trigger calcBusinessHours caused an unexpected exception, contact your administrator: calcBusinessHours: execution of BeforeInsert caused by: System.MathException: null: (System Code)"

 

trigger calcBusinessHours on Task (before insert) {

BusinessHours stdBusinessHours = [select id from businesshours where id = '01m20000000LPVT'];

for (Task ta : Trigger.new) {
if ((ta.recordtypeid == '012M00000008bZY') && ta.status != 'completed' ){
// CL works 10 hours / day (8:00 AM - 18:00 PM, M-F). Our task SLA is 2 hours (2 business hours)
ta.SLA_Due_Date__c = BusinessHours.addGmt (stdBusinessHours.id, ta.createddate, 2 * 60 * 60 * 1000L);
}
}
}

 

Hi,

 

As I understand, email workflows are not permitted in SFDC.

 

I need to email a task owners manager (Task Owner > Manager) if a checkbox on the task = True.

 

Is there anyway to achieve this via apex?

 

Thanks

 

Adam

Hi,

 

I have a custom field on the opportunity object named 'contact__c'. This is a simple lookup field.

If populated I want a trigger that creates an Opportunity contact role for that same contact.

 

Any ideas?

 

I can update the contact__c field based on the primary contact role but I need this work the other way round.

 

Any ideas?

 

Thanks

 

 

Hi,

 

I'm trying to pull through some details relating to a case owner.

I have workflows that fire if a case is owned by a queue that work fine.

I now just want to fire back a text field from the related user (a custom relationship field) but it doesn't seem to populate:

 

There are no errors on the code it just doesn't populate even though the field is populated on the user record.

 

thanks

 

trigger region on case (before Insert, before Update) {

for(case x : Trigger.New){

if(x.User__c == null)
{
x.case_owner_region__c = x.RCCM_region__c ;}
else if(x.User__c!= null)
{
x.case_owner_region__c = x.user__r.region__c ;
}
}

}

 

Hi,

 

We are using SFDC email to case.

Is there a way to search a text area (body of the email) for a unique number and populate this to a field within the case object?

 

The unique number always follows this format e.g FY554077

(2 letters followed by 6 numbers).

 

Many thanks

 

 

trigger volumes on case (before Insert, before Update) {
        for(case x : Trigger.New){        
                     

       if (x.region__c == 'South West'){   
           x.consignments_volumes__c = Volumes__c.getinstance('1. January 2012 SW').Id__c; 

       if (x.region__c == 'North West'){   
           x.consignments_volumes__c = Volumes__c.getinstance('2. February 2012').Id__c;
                            
} 
   }}}

Hi, relatively new to this so I appreciate any help!

 

Can anyone advise why this trigger does not work? it's referencing a custom setting.

 

If I remove the 'if' line, then it seems to work. Any ideas?

 

Thank you

 

 

Hi,

 

I have this trigger. I want to expand, so that upon insert or update a case will automatically populate a lookup field to a custom object:

trigger volumes on case (before Insert, before Update) {
        for(case x : Trigger.New){        
        if (x.region__c == 'south west' & x.financial_period__c == '1. January 2012'){   
       x.Cons__c = 'a0iM0000001cI6F';                                     
} 
   }

 How can i avoid hard coding the record ids, so that when I deploy to another environment the trigger will work?

 I understand I could use custom settings but I have never used these before.

 

Thanks

 

 

 

 

Hi,

 

Is the following possible?

 

I have create a new custom object (let's call it custom__c).

This holds records that I want a case to be related to, if the case meets a certain criteria. I want to automatically populate the look up field on the case. Is this possible? and how would I do this without hardcoding the record id's?

 

e.g

 

if case_region__c = 'x'

& case__date__c = 'y'

custom__r /custom__c = record id of parent record to relate.

 

Many thanks, as always.

 

 

Hi,

 

I have a trigger that send an email when a checkbox is set to true on a task. The check box is set to true via a time based workflow.

However where 2 or 3 tasks are updated at the same time the email trigger is failing with this error message:

 

System.Que​ryExceptio​n: List has more than 1 row for assignment to SObject Trigger.Wo​rkflowEmai​l: line 5, column 1

 

Any ideas how I modify to handle more than 1 record at a time?

 

Thanks

 

 

 

Hi,

 

I have the following code that I would like to populate a date / time field to 2 hours after task creation date (in business hours).

 

This works fine if i set this to after or before update. but i need it to work upon insert of a new task.

currently it fires this error:

 

"Review all error messages below to correct your data.
Apex trigger calcBusinessHours caused an unexpected exception, contact your administrator: calcBusinessHours: execution of BeforeInsert caused by: System.MathException: null: (System Code)"

 

trigger calcBusinessHours on Task (before insert) {

BusinessHours stdBusinessHours = [select id from businesshours where id = '01m20000000LPVT'];

for (Task ta : Trigger.new) {
if ((ta.recordtypeid == '012M00000008bZY') && ta.status != 'completed' ){
// CL works 10 hours / day (8:00 AM - 18:00 PM, M-F). Our task SLA is 2 hours (2 business hours)
ta.SLA_Due_Date__c = BusinessHours.addGmt (stdBusinessHours.id, ta.createddate, 2 * 60 * 60 * 1000L);
}
}
}

 

Hi,

 

As I understand, email workflows are not permitted in SFDC.

 

I need to email a task owners manager (Task Owner > Manager) if a checkbox on the task = True.

 

Is there anyway to achieve this via apex?

 

Thanks

 

Adam

Hi,

 

I have a custom field on the opportunity object named 'contact__c'. This is a simple lookup field.

If populated I want a trigger that creates an Opportunity contact role for that same contact.

 

Any ideas?

 

I can update the contact__c field based on the primary contact role but I need this work the other way round.

 

Any ideas?

 

Thanks

 

 

Hi,

 

I'm trying to pull through some details relating to a case owner.

I have workflows that fire if a case is owned by a queue that work fine.

I now just want to fire back a text field from the related user (a custom relationship field) but it doesn't seem to populate:

 

There are no errors on the code it just doesn't populate even though the field is populated on the user record.

 

thanks

 

trigger region on case (before Insert, before Update) {

for(case x : Trigger.New){

if(x.User__c == null)
{
x.case_owner_region__c = x.RCCM_region__c ;}
else if(x.User__c!= null)
{
x.case_owner_region__c = x.user__r.region__c ;
}
}

}

 

I want to add a button on edit page of a record (say button which opens an external URL in a new window, may be a a url for reference). How do I achieve so?


There's always option of overriding with visualforce page, but there's lot of pitfalls around that approach (say a new recordtype or field is added, you need to create new visualforcce page or update the page respectively etc)

Any idea on how to achieve this? 

 

Chirag

I am trying to create a trigger that will fire off a email to a user when the assign to person completes their activity.

 

how do i add a email template to this trigger below?

 

trigger Trigger_Request_CompletedAfterInsertAfterUpdate on Task (after insert, after update)
 {
    
 
   Task[] completedTasks = Trigger.new;
   for(Task t : completedTasks){
      if(t.RecordTypeId == '01270000000UGMe' && t.Status=='Completed'){
         Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
        
      }
   }
}

 

  • July 22, 2011
  • Like
  • 0