• trustchris
  • NEWBIE
  • 55 Points
  • Member since 2010

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

Hi,

 

Can someone give me an example of writing jquery in VFpages.

Hi All

 

I am trying to create a script that checks domains to make sure they are of the correct format.  I have succesfully compiled my regex and and can use this with the Matcher method to check that the input string is of the correct format.  for example.

 

boolean  myMatcher = Pattern.matches('\\w*-*\\w*[^-].com.au', 'google.com.au');
system.assert(myMatcher);

//this code will execute succesfully in the system log.

 

This is fine when I want to confirm a whole string, but when trying to match a patial string I thought I'd be able to use the lookingAt method to dtirmine the regionStart & regionEnd points and extract the part of the domain that is useful.

 

Using the lookingAt method, I would expext the following code to execute succesfully.

 

pattern myPattern = pattern.compile('\\w*-*\\w*[^-].com.au');
system.debug('the pattern is - '+ myPattern.pattern());
boolean myMatcher = myPattern.matcher('www.google.com.au').lookingAt();
system.assert(myMatcher);

//does not find the google.com.au domain in www.google.com.au.

 

It seems as though the lookingAt method is the same as the Matcher method and is attempting to match the whole string.

 

Maybe it's just my understanding of how this works that is wrong?  Anybody got any ideas?

 

Cheers

 

I am unsure what I have done wrong in this test code. It is telling me I have 0% coverage but I feel like it should be telling me 100%. Below is my trigger and test code.

 

Trigger Code:

 

 

trigger storeID on Lead (before insert, before update) {
        
    //variable to hold store number    
    string storeNumber;
    
    //for loop to go through new trigger instances and assign Dealer_Number__c to store variable
    for(Lead l : Trigger.new)        
        storeNumber = l.Dealer_Number__c;
   
    //SOQL query to find account account(store) id from the account(store) that has the same AccountNumber as lead store number
    account a = [SELECT id FROM Account WHERE AccountNumber = :storeNumber];
        
    //for loop to go through trigger and assign account(store) id to lead lookup field Dealer__c
    for(Lead l : Trigger.new)
        l.Dealer__c = a.id; 
              
}

 Test Code:

 

@isTest
private class testLeadStoreIDs {

    static testMethod void myUnitTest() {
            
        account store = new account();
    	store.name = 'test store';
    	store.type = 'other';
    	store.AccountNumber = '123456';
    	insert store;

    	Lead[] leadsToCreate = new Lead[]{};
    	for(Integer x = 0; x<200; x++){
        	Lead l = new Lead();
        	l.LastName = 'last';
        	l.Company = 'test company';
        	l.Status = 'Open';
        	l.Dealer_Number__c = '123456';
    	}

    	//Test.startTest();
    	insert leadsToCreate;
    	//Test.stopTest();
    }
}

 Any advice on how I can get this test code to work would be appreciated. 

 

- Jim Hutcherson

 

 

I have a field which is a checkbox but in my VF page I want to display it as a radio with the options of Yes or No

 

I am using selectradio but the problem is it is defaulting to selecting the No value. I believe the reason for this is that since the checkbox itself is not set, its value is false which is then being reflected in the radio. This is expected behavior, I guess. But I need it so that no value is selected, so we can force validation to verify they chose something.

 

Anybody have an idea how to do this?

 

 

	public List<SelectOption> getYesNo() { 
		List<SelectOption> options = new List<SelectOption>();
		 options.add(new SelectOption('true', 'Yes'));
		 options.add(new SelectOption('false', 'No'));
		return options;
	}

 

<apex:SelectRadio id="radio" value="{!myobj.mycheckboxfield__c}">
     <apex:selectOptions value="{!yesno}"/>
</apex:SelectRadio>

 

 

 

  • April 29, 2011
  • Like
  • 0

Hi, I'm getting the error returned in an exception. "Unable to retrieve object"

I get this when I am trying to attach a PDF To an email.

 

  • The PDF works perfectly fine.
  • The page and code are both set to API 21.0.
  • The ID of the PDF is correctly being set and is valid.
  • I am trying to send this email via a site guest profile.
  • It has worked before... but only twice.
  • I am not running this through a test (I know how to fix that one!).

 

Here is where it's falling over:

 

PageReference pdf = Page.ShowInvoice;
pdf.getParameters().put('id', (String)invoice.Id);
Blob pdfContent = pdf.getContent();

 

Any ideas?

 

Hi,

 

Can someone give me an example of writing jquery in VFpages.

Hi All

 

I am trying to create a script that checks domains to make sure they are of the correct format.  I have succesfully compiled my regex and and can use this with the Matcher method to check that the input string is of the correct format.  for example.

 

boolean  myMatcher = Pattern.matches('\\w*-*\\w*[^-].com.au', 'google.com.au');
system.assert(myMatcher);

//this code will execute succesfully in the system log.

 

This is fine when I want to confirm a whole string, but when trying to match a patial string I thought I'd be able to use the lookingAt method to dtirmine the regionStart & regionEnd points and extract the part of the domain that is useful.

 

Using the lookingAt method, I would expext the following code to execute succesfully.

 

pattern myPattern = pattern.compile('\\w*-*\\w*[^-].com.au');
system.debug('the pattern is - '+ myPattern.pattern());
boolean myMatcher = myPattern.matcher('www.google.com.au').lookingAt();
system.assert(myMatcher);

//does not find the google.com.au domain in www.google.com.au.

 

It seems as though the lookingAt method is the same as the Matcher method and is attempting to match the whole string.

 

Maybe it's just my understanding of how this works that is wrong?  Anybody got any ideas?

 

Cheers

 

Hi All,


 Appreciate if you could help me correct this trigger

When a custom field(Is_Serviceable__c) on the custom object (Product_Master__c) is true, then create or update the fields on Asset by the fields of custom object(Contract_Product__c).

trigger UpdateAsset on Product_Master__c (after insert, after update) {

        //List Asset to insert, update

      List<Asset> insertASList      = new List<Asset>();

      List<Asset> updateASList      = new List<Asset>();

 

      for(Product_Master__c pm:trigger.new){

      for(Contract_Product__c cp:trigger.new){

     //check for the checkbox

      if(trigger.isinsert && trigger.isafter && pm.Is_Serviceable__c==true){

     cp.add(new Contract_Product__c(Contract_Start_Date__c=AS.Contract_Start_Date__c, Contract_End_Date__c=AS.Contract_End_Date__c));

      }

     //check for the checkbox update on Product_Master__c

      if(trigger.isupdate && trigger.isafter && pm.Is_Serviceable__c==true){

     cp.add(new Contract_Product__c(Contract_Start_Date__c=AS.Contract_Start_Date__c, Contract_End_Date__c=AS.Contract_End_Date__c));

      }  

    }

      }

    insert insertASList;

    update updateASList;

 

}

 

}