You need to sign in to do that
Don't have an account?
Plainview
Logic to return "null" if Contact Country is not United States.
Hello,
I am a new System Admin. obliged to function above my ability - so what else is new?
We use an Apex Class "ProvisioningInfo," which is tied to a Visualforce page button users may select on the Contract object layout that feeds the Billing Contact information into a system called Back Office. I would like to know the "what" and "where" to add some logic to the class so that it returns "null" if the Billing Contact country is not the United States. Thanks for your time!
Here are some screen shots of what I believe are the relevant areas in the Apex code:
I am a new System Admin. obliged to function above my ability - so what else is new?
We use an Apex Class "ProvisioningInfo," which is tied to a Visualforce page button users may select on the Contract object layout that feeds the Billing Contact information into a system called Back Office. I would like to know the "what" and "where" to add some logic to the class so that it returns "null" if the Billing Contact country is not the United States. Thanks for your time!
Here are some screen shots of what I believe are the relevant areas in the Apex code:
if(admincontact.contact.mailingcountry == 'United States')
{ boma.StateId = BOlookupMaps.getStateISO(adminContact.Contact.MailingState); }
else
{ boma.StateId = ''; }
All Answers
if so then add
AND Countact.MailingCountry == 'United States'
on the end of line 649 & 670
thanks
dan
Thanks for your response. Ah, I wish that was it but ... no, that's not quite it.
If the country of the Billing Contact is not the United States, we want to automatically fill in the field with "null" or "n/a" so tha that the user will have to complete it and so we won't get an error message. Back Office is not great at recognizing foreign country codes. Is that clearer? Sorry for the confusion.
Best,
Julien
that basically fires when the country is not equal to united states - to avoid it firing again and again do it when the record is created only..
then you can set the field update to change country to null or n/a
hope that helps
So, our process is:
A contract is created;
From the contract object, the user selects an Apex Class button entitled "Create Provisioning Case";
A VisualForce page is then opened (Apex Class "ProvisioningInfo") which has another button available entitled "Create Back Office Master Account";
When the user selects this button, the system is currently returning the following error message when the Billing Contact country is not USA:
We want the system to fill in "null" or "n/a" for the Back Office Master Account when the country is not USA.
Our instance is heavily customized at this point, so even the simplest things become complex it seems.
Any and all advice is appreciated.
you've highlighted something that i'd like to see the method it's calling
Bolookupmaps.getcountryiso - any chance you can share that bit of code - i reckon in there i'll should be able to advise on some logic..
on line 152 update to something like this.
if(admincontact.contact.mailingcountry == 'United States'){
boma.CountryID = bolookupmaps.getcountryiso(admincontact.contact.mailingcountry);
}
if(admincontact.contact.mailingcountry != 'United States'){
bome.CountryID = null; // or you could put 'n/a'
}
i'd still like to see the bolookupmaps as i think this still might through an error but in theory the logic will only get the isocode the United States..
cheers
dan
although it would be interesting to see what the code is doing.. if you have an account on https://gist.github.com/ - you could just paste it there and share the link..
Last line should be: "boma" right? (you had "bome.CountryID = null; // or you could put 'n/a'", so I'm just thinking typo and fixed it).
OK, it seems to be working in our Sandbox but we can't test it in Production until next Tuesday probably (I'm leaving soon for a four day birthday weekend - woohoo!) I'll circle back and let you know! Thanks again, Dan, so very much.
Cheers,
J
happy birthday
note. pre deployment you should check your test class to make sure that your testing for my if statement - i.e. intentionally through in a non United States country to make sure the new lines are tested..
have a good one
dan
Secret GIST fyi:
https://gist.github.com/jcamp6/39728b3f6c1c65e04774
Midnight! Yikes! Good God Man, go to sleep!
I'll let you know on Tuesday or Wednesday.
Three cases tested. Results, in summary:
1.)
City: Curitiba
Country: Brazil
State: PR (Parana)
--> The create account button was there and worked to create the BO Account but it entered Puerto Rico because "PR" state is Puerto Rico on the pull-down (or the code?).
2.)
For Any City, Puerto Rico the button did not come up at all.
3.)
https://c.na0.visual.force.com/apex/ProvisioningInfo?id=80000000000OS5f&caseID=500000000098YKh&caseNum=00372874&isdtp=vw&nonce=f6c25f7a639ff373f258cf950de4552571d0a1aa31f30c5db2cc63fd09a60b12&sfdcIFrameOrigin=https%3A%2F%2Fssl.salesforce.com
City: Curitiba
Country: Brazil
State: None entered
It defaulted the Country to USA instead of Brazil.
if(admincontact.contact.mailingcountry == 'United States')
{ boma.StateId = BOlookupMaps.getStateISO(adminContact.Contact.MailingState); }
else
{ boma.StateId = ''; }