• DuTom
  • NEWBIE
  • 50 Points
  • Member since 2008

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

Hi,

 

I am trying to show the standard contact edit page without a sidebar. Is it possible to turn it off ?

The reason is I want to show the "Edit Contact" page in a jQuery popup. But having the sidebar and header takes up too much screen real estate.

 

Any ideas would be helpful.

 

Thanks.


This question is from  my practise when we update a field on the account object when there is an action on the contact object do we need to mention the particular record type of the record to make the update by a trigger.

 

Why Iam asking this is by the following code i noticed an error on the contct obj but where as not on the opportunity

 

The compiler error is AccountId does not exist.

With some modifications a part this code i tested with the opportunity obj, but there is no error.

trigger primaryPhone on Contact(before Insert){

 set<Id> ids = new set<Id>();
for(Contact cnt : Trigger.New){

ids.add(cnt.AccountId);
}
Map<Id, Account> accMapIds = new Map<Id, Account>([Select Id,Phone from Account where Id
IN: ids]);
List<Account> act = new List<Account>();
for(Contact ct : trigger.New){
if(ct.Primary__c == True){
Account acc = accMapIds.get(ct.AccountId);
acc.Phone = ct.Phone;
act.add(acc);
}
}
Update act; 
}

 

Plz share your ideas and suggestion

Thanks in advance

 

I configured remote Access(OAUTH) to use a certificate however this is not work as I expected.   It seems the OAUTH services grants access regardless of the client  (I.E. does not validate the client even though I have checked the 'My App uses digital signatures for login' and added the client cert)

 

Also this was is being test in a sandbox, so not sure if that has anything to do with it.

 

-Tom


 


 

  • March 02, 2012
  • Like
  • 0
Is two-way binding supported with a <apex:component >?  The code below shows my unsuccessful attempt to two-way bind my custom component back to my controller on the page.  Please advise,
 
-Tom
 
 
 
Code:
 
numScroll:
<apex:component >
<apex:attribute name="value" description="binding value for the component." type="String" required="true"/>
<apex:inputText value="{!value}" size="4"/>
</apex:component>


<apex:page controller="RequestWizard_Controller" action="{!init}">
...
    <apex:pageBlockTable value="{!SearchResults}" var="sr" width="100%" rendered="{!NOT(ISNULL(SearchResults))}">
        <apex:column ><c:numScroll value="{!sr.quantity}" ></apex:column> 
        <apex:column headerValue="UOM" value="{!sr.catalogItem.Unit_of_Measure__c}"/>
        <apex:column headerValue="Code" value="{!sr.catalogItem.Name}"/>
        <apex:column headerValue="Name" value="{!sr.catalogItem.Catalog_Item_Name__c}"/>
        <apex:column headerValue="Supplier" value="{!sr.catalogItem.Catalog__r.Fulfillment_Supplier__c}"/>
        <apex:column headerValue="Catalog" value="{!sr.catalogItem.Catalog__r.Name}"/>
        <apex:column headerValue="Limit" value="{!sr.catalogItem.Quantity_Limit_Max__c}"/>
    </apex:pageBlockTable> 
...

</apex:page>

 
  • August 27, 2008
  • Like
  • 0

Using Apex in a trigger, how can one find the current SFDC instance (the pod - like "cs3") when in a sandbox logged in under a My Domain?  Using Url.getSalesforceBaseUrl().getHost(); doesn't seem to get us there.

Hi,

 

I am trying to show the standard contact edit page without a sidebar. Is it possible to turn it off ?

The reason is I want to show the "Edit Contact" page in a jQuery popup. But having the sidebar and header takes up too much screen real estate.

 

Any ideas would be helpful.

 

Thanks.


This question is from  my practise when we update a field on the account object when there is an action on the contact object do we need to mention the particular record type of the record to make the update by a trigger.

 

Why Iam asking this is by the following code i noticed an error on the contct obj but where as not on the opportunity

 

The compiler error is AccountId does not exist.

With some modifications a part this code i tested with the opportunity obj, but there is no error.

trigger primaryPhone on Contact(before Insert){

 set<Id> ids = new set<Id>();
for(Contact cnt : Trigger.New){

ids.add(cnt.AccountId);
}
Map<Id, Account> accMapIds = new Map<Id, Account>([Select Id,Phone from Account where Id
IN: ids]);
List<Account> act = new List<Account>();
for(Contact ct : trigger.New){
if(ct.Primary__c == True){
Account acc = accMapIds.get(ct.AccountId);
acc.Phone = ct.Phone;
act.add(acc);
}
}
Update act; 
}

 

Plz share your ideas and suggestion

Thanks in advance

 

Hi,

 

Need help with getting the test class to 100% as I'm having trouble with a couple of lines which may help with future testing.

 

1.) Trigger on Opportunity

 

trigger SetAgent on Opportunity (before insert, before update) { 
List<String> accountIds = new List<String>();
List<Account> parentAccounts = new List<Account>();
for(Opportunity oppty : Trigger.new)
{
accountIds.add(oppty.AccountId);
}
 parentAccounts = [Select Id, Agent__c from Account where Id in :accountIds];
    Map<String,Account> accountMap = new Map<String,Account>();
     for(Account a : parentAccounts)
    {
        accountMap.put(a.Id,a);
    }
   for(Opportunity oppty : Trigger.new)
    {
        Account parentAccount = accountMap.get(oppty.AccountId);
        if(parentAccount != null)
        {
            oppty.Agent__c = parentAccount.Agent__c;
        }
    }
}

 2.) Apex Test Class 

 

@isTest
private class SetAgentTest {
    static testMethod void SetAgent() {
        Account a = new Account(Id = '001K000000KnlcE', Agent__c = 'a03K0000001A7v2');        
        Opportunity o = new Opportunity(Name = 'TestOpportunity', StageName = 'Prospecting', CloseDate = system.Today(), Agent__c = a.Agent__c);
        insert o;
        System.assertEquals(a.Agent__c, o.Agent__c);
    }
}

 3.) The 83% result tells me that these two lines from the code above were not tested, a brief explanation of why would be much appreciated.

 

accountMap.put(a.Id,a);

 

oppty.Agent__c = parentAccount.Agent__c;

 Thanks again!

  • October 26, 2012
  • Like
  • 0

Hi,

how to write a test class single email message

 

public class emailclass1
{
public String error{get;set;}
public String successMsg{get;set;}
public List<String> addresses {get;set;}
public boolean flagToSendMail;
public string plainbody{get;set;}
public string Email{get;set;}
public string Cc{get;set;}
public string BCc{get;set;}
public string subject{get;set;}
public attachment attach{get;set;}
public string Richtext{get;set;}
public emailclass1()
{
system.debug('^^^^^^'+attach);
attach=new attachment();
}
public String message {get;set;}


public pagereference send()
{
if(Email==null|| Email=='' || attach==null)
{
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.FATAL, 'Please check your uasername and email id');
ApexPages.addMessage(myMsg);
return null;
}
else
{

if(Email != '' || cc != '' || bcc != '' || attach!=null)
{
List<String> toAddresses = new List<String>();
List<String> ccAddresses = new List<String>();
List<String> bccAddresses = new List<String>();

List<String> tmpAddr = new List<String>();
if(Email.contains(','))
{
toAddresses = Email.split(',');
for(String tmp:toAddresses)
{
tmpAddr.add(tmp);
}
}
else if(Email != '')
{
toAddresses.add(Email );
tmpAddr.add(Email);
}
if(cc.contains(','))
{
ccAddresses = cc.split(',');
for(String tmp:ccAddresses)
{
tmpAddr.add(tmp);
}
}
else if(cc != '')
{
ccAddresses.add(cc);
tmpAddr.add(cc);
}
if(bcc.contains(','))
{
bccAddresses = bcc.split(',');
for(String tmp:bccAddresses)
{
tmpAddr.add(tmp);
}
}
else if(bcc != '')
{
bccAddresses.add(bcc);
tmpAddr.add(bcc);
}

addresses = tmpAddr;
for(String tempStr:addresses)
{
if(!Pattern.matches('[a-zA-Z0-9._-]+@[a-zA-Z]+.[a-zA-Z]{2,4}', tempStr))
{
error = 'Check To, CC and BCC addresses';
successMsg = '';
flagToSendMail = false;
break;
}
else
{
flagToSendMail = true;
}
}


if(flagToSendMail == true)
{
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
if(toAddresses != null)
{
mail.setToAddresses(toAddresses);
}
if(toAddresses != null)
{
mail.setccAddresses(ccAddresses);
}
if(toAddresses != null)
{
mail.setbccAddresses(bccAddresses);
}
Messaging.EmailFileAttachment[] fileAttachments = new Messaging.EmailFileAttachment[]{};
Messaging.EmailFileAttachment pdfFileAttachment = new Messaging.EmailFileAttachment();
pdfFileAttachment.setBody(attach.body);
pdfFileAttachment.setFileName('file xlsx');
fileAttachments.add(pdfFileAttachment);


mail.setToAddresses(toAddresses);
mail.setCcAddresses(CcAddresses );
mail.setBCcAddresses(BCcAddresses );
mail.setSubject(subject);
mail.setPlainTextBody(plainbody);
//mail.setFileAttachments(new Messaging.EmailFileAttachment{attach});
mail.setFileAttachments(fileAttachments );

Messaging.SendEmailResult[] sendResult = Messaging.sendEmail(new Messaging.SingleEmailMessage[]{mail});


}
}


//ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.FATAL, 'Email sent successfully');
//ApexPages.addMessage(myMsg);
Email='';
subject='';
plainbody='';
cc='';
bcc='';

 

 

}
return null;
}


}

 

 

 

My test class

 

@istest
private class emailtestclass
{
static testmethod void test()
{


Attachment attach=new Attachment();



Messaging.EmailFileAttachment pdfFileAttachment = new Messaging.EmailFileAttachment();
Messaging.SingleEmailMessage mail1 = new Messaging.SingleEmailMessage();
mail1.setPlainTextBody('plainbody');
emailclass1 mail=new emailclass1();

pdfFileAttachment.setBody(attach.body);
pdfFileAttachment.setFileName('file xlsx');


mail.Email='suresh@gmail.com,suresh.a@gmail.com';
mail.cc='suresh.p@gmail.com,suresh.ar@gmail.com';
mail.bcc='suresh@gmail.com,suresh.ad@gmail.com';
mail.send();

mail.Email='suresh.a@gmail.com';
mail.cc='';
mail.bcc='';
mail.send();

}
static testmethod void test1()
{


}
}

 

 

 

i got an error like

 

System.EmailException: SendEmail failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Missing body, need at least one of html or plainText: []Class.emailclass1.send: line 129, column 1 Class.emailtestclass.test: line 24, column 1

 

 

Please help me

 

Effectively I'm trying to recreate the Bounced Email Tracking on the standard Lead object. It would be very useful if Email Addresses on custom objects where able to be marked as a bounced email if the workflow email alert bounces.

 

Any direction on how to accomplish this would be much appreciated.

  • February 15, 2011
  • Like
  • 0

Any way to serve manifest files from SFDC, static resource, vf page, other with mime type 'text/cache-manifest'?

  • August 09, 2010
  • Like
  • 0
Hi All,

The short story behind this post is that I would like to know whether there is a way to make calls from Apex to an external web service without using the external web service WSDL.

The longer story now. The support provided by Sales Force through Apex to call external web services is great. One can simply take the external web service WSDL, and Sales Force will generate from it the necessary Apex classes to consume that web service. However, here there is an intrinsic assumption that the external web service use SOAP RPC type of message. There are other type or styles of communicating via SOAP such as the "Document" or "Message" style that just exchange XML, and it is the responsability of the caller to that service to generate the proper XML - that would be the structure required by the service including the input parameters. There are a lot of services out there that work in this way but in order to use them from Apex one would need some sort of package/library in Apex that allow one to create and manipulate SOAP messages, very much along the lines of SAAJ in Java. Is there such a package/library in Apex ?.

One related issue is when the web service has a WSDL that cannot be parsed by Sales Force. Here again it would be useful to have such package/library to handle the raw SOAP messages.

I wonder if people have had any experience on this issue and what was the approach they have taken. I guess that one brutal force approach would be to generate the SOAP messages manually just  manipulating  string objects, but  I do not think this is such a good idea.

I would be most grateful for any comments/views on this, and to the developement team, whether there are any plans to support that, or what is the rationale no to do so.

Thank you very much in advance,
Fernando
Hi all,

I might be sounding childish but..it is

Iam trying to deploy a trigger from sandbox onto production instance using Force.com IDE.

When i select the project ->Force.com IDE-> i donot see any option to deploy the trigger on production

Iam using eclipse 3.2 and respective Force.com IDE.

Pls help

Thanks
Kumar
  • August 27, 2008
  • Like
  • 0
I have some Territory Assignment rules based on Account fields that are filled in by a trigger execution. The problem is that the assignment rules never apply in that way, but if the field is modified through Salesforce interface they are applied. I know that there is a SOAP header I have to use when inserting Accounts through API Web services in order to get assignment rules executed, but what about that in Apex?
I haven't found any reference that states that Apex doesn't trigger Territory Assignment rules, but my tests lead me to think so, and it is a very big problem in our org.