• Tbom
  • NEWBIE
  • 127 Points
  • Member since 2008

  • Chatter
    Feed
  • 4
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 42
    Replies

I am trying to set an apex trigger to send an email template to the account owner once a case has been created.

The email side work ok but i cannot pick up the account owner's email address.

 

Below is the code i have tried, a mix from other sources as i have little salesforce knowledge.

trigger emailToAM on Case (after insert) {
          
for (Case c : trigger.new) {          
    String[] showID = new String[] {c.OwnerId}; 
    List<User> u = [SELECT Id, Name, Email FROM User WHERE Id in :showID];
    String[] toAddresses = new String[] {u.id};  
    
    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

    // Strings to hold the email addresses to which you are sending the email.  
  
    mail.setToAddresses(toAddresses);
    mail.setReplyTo('noreply@salesforce.com');
    mail.setSenderDisplayName('Call Reception Unit');
    mail.setBccSender(false);
    mail.setUseSignature(false);
    mail.setTargetObjectId(c.ContactId);
    mail.setTemplateId('00XS0000000Ijgl');  
    
    Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
    }
}

 

I get an error when trying to compile:

Error: Compile Error: Initial term of field expression must be a concrete SObject: LIST:SOBJECT:User at line 6 column 42 

 

Any help much appreciated.

  • April 20, 2010
  • Like
  • 0
Hi
Lets say we Clicked Account tab. Number account records have been displayed. It has field Contract Id .
As of now it is just a non clickable field. I need to make it a hot link, so that as soon as user clicks on it, it should take to the Contract Page.

Any Idea how to do that???

Silly question here but:  Does the unique MyDomain qualify for both production and sandbox instances? I would think so, but just want to double check out there.

 

So I could:

Register "crazydomain" in the sandbox and have:

https://crazydomain--crazydev.cs3.my.salesforce.com

 

And register "crazydomain" in Production and have:

https://crazydomain.my.salesforce.com 

 

(of course, I'd have to reserve/register in both places)

  • September 11, 2012
  • Like
  • 1

From the SFDC docs, is says "execute()" only allows one callout.   However, the limit for total callouts (in our case HTTP requests) for a given Apex request is 10.

Question: is the Batch Apex routine considered a single Apex request OR is each Batch within considered a single Apex request?

 

Hoping the latter so that we may make around 50 calls a night via a scheduler.  Seems like it must be so.  If anyone know for sure, please let me know.

 

Thanks

  • December 20, 2011
  • Like
  • 0

I remember seeing a technique in a native SFDC layout where there was "tiny" VF page being used to look like a "field" on the native layout.

 

Anyone use this before and/or know how it was done?  

 

Thanks

  • August 17, 2011
  • Like
  • 0

Hi,

I see with versions 20.0+ you can get access to the Report object.  What I'm not finding is whether you can then get the Report result in Apex... or rather attach the rendered Report in email (in Apex.)  

Would that be too good? or am I just missing something simple?

 

In the past I've had to construct custom csv files within Apex, convert to blob, and use it as an attachment.  

 

Thanks,

Tom

  • February 08, 2011
  • Like
  • 0

So I have (had) a fine Visualforce page working for the past year that suddenly doesn't work in Winter '11. 

Specifically the ajax part that rerenders some custom (Lookup to related records) picklists base on the "onchange" actionSupport attribute.

Did something change in Winter '11..?   Here's my vf code:

 

 

<apex:outputLabel value="*Locations" for="locations"/>          
<apex:selectList value="{!selectedLocationOption}" size="1" id="locations">
  <apex:selectOptions value="{!dependentLocationStrings}"/> 
  <apex:actionSupport event="onchange" rerender="careers"/>          		            
</apex:selectList> 

 

I'm able to get the proper results back if I keep hitting the "Send" button with missing form criteria (like First Name) so that my custom form validation fails (on purpose.)  But previously (Oct.'09 through last week) this just worked based on user selection and onchange event.

I've replicated the faulty behavior in FF, Safari, Chrome, and IE 6.

 

 

 

  • October 12, 2010
  • Like
  • 0

Anyone know if SOQL or SOSL is available for SFDC Content and Knowledge/Articles objects?

Upon some quick research, it doesn't seem like it...

 

I'm thinking of trying to build a custom single seach mechanism (that searches Content and Knowledge.)  However it needs to be available to portal users... so the new Global Search will not work,, hence the custom..

 

Thanks

  • October 04, 2010
  • Like
  • 0

what's the query limit within an Apex class called by the Apex Code Scheduler? 1000 or 10000?

  • April 19, 2010
  • Like
  • 0

Hi, I'm trying to get the SFGA code to work with a Lead creation on a website that uses a Visualforce page (Sites.) So far no go.  I've queried the various SFGA objects through the IDE and no records are getting created... which means that the http://lct.salesforce.com/sfga.js isn't doing its thing I believe.

Does anyone know if this is possible and/or supported?  I haven't been able to find any documentation or examples on it.

 

Thanks --

 

Here's the end of my VF code:

... many fields like the one below
<apex:outputLabel value="Other Comments: " for="comments" />
<apex:inputTextArea id="inputComments" value="{!lead.Other_Comments__c}" />

<apex:commandButton action="{!saveLead}" value="Send" id="sendButton" />
</apex:panelGrid>
</apex:outputPanel>

<input type="hidden" name="oid" value="theSFDC_ORG" />
<input type="hidden" name="retURL" value="http://theurl.force.com.mysuccesspage" />
<input type="hidden" name="landing" id="landing" />
<input type="hidden" name="referrer" id="referrer" />

<input type="hidden" name="sfga" value="theSFDC_ORG" />

</apex:form>

<apex:includeScript value="https://lct.salesforce.com/sfga.js"/>
<script type="text/javascript">_sfga();</script>
</body>
</apex:page>

  • December 14, 2009
  • Like
  • 0

Can a field update from within an Approval Process trigger a new Workflow (in this case timed-based)? From what I've read in various random posts over last 2 years, the answers no. Just want to see if there's any new news on this.. perhaps Summer '09.

Thanks.

  • June 26, 2009
  • Like
  • 0

Silly question here but:  Does the unique MyDomain qualify for both production and sandbox instances? I would think so, but just want to double check out there.

 

So I could:

Register "crazydomain" in the sandbox and have:

https://crazydomain--crazydev.cs3.my.salesforce.com

 

And register "crazydomain" in Production and have:

https://crazydomain.my.salesforce.com 

 

(of course, I'd have to reserve/register in both places)

  • September 11, 2012
  • Like
  • 1
We are trying to configure Zendesk to authenticate against SalesForce Community User accounts using SSO.  So far, we've successfully configured Zendesk to authenticate against SalesForce internal user accounts, but not Community User accounts.

The current setup is relatively straightforward...
We configured a Domain per these docs: https://help.salesforce.com/apex/HTViewHelpDoc?id=service_provider_prerequisites.htm&language=en_US
Single Sign-on with SalesForce as the Identity Provider and a Connected App for Zendesk, in a similar fashion to these docs: https://developer.salesforce.com/page/Configuring-SAML-SSO-to-ZenDesk

Amongst the many things I've tried, I tried changing the "Identity Provider Login URL" on the SAML Single Sign-On Setting page to point to our Community custom login page, which at least redirects the user trying to login to Zendesk to the right login page.  However, the SAML assertion doesn't work and the user is not redirected back to Zendesk after login.

I have found no documentation or articles on using SSO authenticating against Community user accounts, so any direction from this community would be greatly appreciated!

Silly question here but:  Does the unique MyDomain qualify for both production and sandbox instances? I would think so, but just want to double check out there.

 

So I could:

Register "crazydomain" in the sandbox and have:

https://crazydomain--crazydev.cs3.my.salesforce.com

 

And register "crazydomain" in Production and have:

https://crazydomain.my.salesforce.com 

 

(of course, I'd have to reserve/register in both places)

  • September 11, 2012
  • Like
  • 1

Managed Beta package failed during installation with an unknown error. Logged a case with Salesforce.com

 

The error did not say anything about the reason for the error. It just had a salesforce error number!!!. What help is that ? Salesforce should seriously start thinking on working towards spitting correct, useful informational error messages that can help diagnose the cause of the error.

 

Error:

Your requested install failed. Please try this again.

None of the data or setup information in your salesforce.com organization should have been affected by this error.

If this error persists, contact salesforce.com Support through your normal channels and reference number: 1922689759-2914 (-727923320)

 

We later found through a series of repackaging and resintalls the reason for the error.

The package included a permission set that had "Read" object permission for a custom child object. The master to the child is the standard Opportunity object. We were trying to set the permissions for opportunity and the child would automatically get the Read permission set due to the master-child relationship. This would generate an error during package install. The package would compile without any error though.

 

So now we know that you cannot set the object permissions in a permission set in a package on a custom object if the object is a child to a standard object through master-child relationship. We wanted to set only Read permission on the custom child object in the permission set so that the user would not be able Delete/Edit the records from UI.(page layouts)

 

You can set the object permissions on a child object to a standard object(master ) in a profile and the package will install successfully. Profiles are better that permission sets (whatever works is best - ugh!!!)

 

Has anyone got this error before? Is not being able to set object permissions on a child object in a permission set a bug or an expected behavior? Can Salesforce please clarify this.

 

 

 

 

 

So I understand we cannot trigger off of the OpportunityContactRole object but someone said I could query the object and then update the opportunity.  I can't seem to figure out the best way to accomplish this.  I have some code that was given to me but I am not sure how I can then populate the opportunity with the contact ID.  Can someone please help?

trigger Contact_Role_Update on Opportunity (after insert) 
{Map<ID, OpportunityContactRole> roles = new Map<ID, OpportunityContactRole>([SELECT Id, Contact.Name, ContactId, IsPrimary, OpportunityId from OpportunityContactRole where OpportunityId in :opportunityidlist ]);

 

From the SFDC docs, is says "execute()" only allows one callout.   However, the limit for total callouts (in our case HTTP requests) for a given Apex request is 10.

Question: is the Batch Apex routine considered a single Apex request OR is each Batch within considered a single Apex request?

 

Hoping the latter so that we may make around 50 calls a night via a scheduler.  Seems like it must be so.  If anyone know for sure, please let me know.

 

Thanks

  • December 20, 2011
  • Like
  • 0

I'm getting an error message periodically: attempt to de-reference a null object on line 79 column 13.  Can someone tell me what's wrong?

 

  • trigger leadRoundRobin on Lead (before insert, before update) {
        //
        //Check if assignment owner has changed
        //
        Map<Integer,Id> queueIds = new Map<Integer,Id>();   //Trigger index --> Queue ID
        
        Integer idx = 0;
        for (Lead cs : Trigger.new)
        {
            if(Trigger.isUpdate) {  
                if(cs.OwnerId <> Trigger.oldMap.get(cs.id).OwnerId) {
                    if (cs.TempOwnerId__c == 'SKIP') {
                        Trigger.new[idx].TempOwnerId__c = '';
                    } else {
                        queueIds.put(idx, cs.OwnerId);
                    }
                }           
            }else {
                queueIds.put(idx, cs.OwnerId);
            }   
            idx++;
        }
        System.debug('>>>>>queueIds: '+queueIds);
        if (queueIds.isEmpty()) return;
        
        //
        //Find active Assignment Group for Queue
        //
        Map<Integer,Id> asgnGroupNameIds = new Map<Integer,Id>();   //Trigger index --> Assignment_Group_Name ID
        Map<Id,Assignment_Group_Queues__c> asgnGroupQueues = new Map<Id,Assignment_Group_Queues__c>(); //Queue ID --> Assignment Group Queues
        
        for(Assignment_Group_Queues__c[] agq : [SELECT Assignment_Group_Name__c, QueueId__c
                                              FROM Assignment_Group_Queues__c 
                                              WHERE QueueId__c in :queueIds.values()
                                              AND Active__c = 'True'])
        {
            for (Integer i = 0; i < agq.size() ; i++) {
                asgnGroupQueues.put(agq[i].QueueId__c, agq[i]);
            }                                           
        }
        System.debug('>>>>>asgnGroupQueues: '+asgnGroupQueues); 
        if (asgnGroupQueues.isEmpty()) return;
    
        for (Integer i : queueIds.keySet()) {
            Assignment_Group_Queues__c agq = asgnGroupQueues.get(queueIds.get(i));
            
            if (agq <> null) {
                asgnGroupNameIds.put(i, agq.Assignment_Group_Name__c);
            }
            //else no active assignment group queue error
        }
        System.debug('>>>>>asgnGroupNameIds: '+asgnGroupNameIds);
        if (asgnGroupNameIds.isEmpty()) return;
        
        //
        //Determine next valid user in Queue/Assignment Group for round robin
        //User with earliest last assignment date wins.
        //
        Map<Id,Assignment_Groups__c[]> asgnGroups = new Map<Id,Assignment_Groups__c[]>(); // Assignment Group Name ID --> User ID
        for(Assignment_Groups__c[] ags : [SELECT Group_Name__c, User__c, Last_Assignment__c, Millisecond__c 
                                       FROM Assignment_Groups__c 
                                       WHERE Group_Name__c in :asgnGroupNameIds.values() 
                                       AND Active__c = 'True' AND User_Active__c = 'True'
                                       ORDER BY Last_Assignment__c, Millisecond__c])
        {
            if (ags.size()>0) {
                asgnGroups.put(ags[0].Group_Name__c, ags);
            }
        }
        System.debug('>>>>>asgnGroups: '+asgnGroups);   
        if (asgnGroups.isEmpty()) return;
    
        Map<Id,Assignment_Groups__c> updateAssignmentGroups = new Map<Id,Assignment_Groups__c>();
        Map<Id, datetime> latestAGDateTime = new Map<Id,datetime>();
        idx = 0;    
        for (Integer i : queueIds.keySet())
        {
            Assignment_Groups__c[] ags = asgnGroups.get(asgnGroupNameIds.get(i));
     if (ags.size()>0)
            {   
                //Choose next user in line if user ID has already been used but not committed in this trigger batch 
                Assignment_Groups__c ag = ags[math.mod(idx, ags.size())];
                    
                //Assign User to Lead as the new owner
                System.debug('>>>>>Owner changed for Lead ' + Trigger.new[i].Id + ' from '+Trigger.new[i].OwnerId+' to '+ ag.User__c);
                Trigger.new[i].OwnerId = ag.User__c;    
                Trigger.new[i].TempOwnerId__c = ag.User__c; 
    
                //Set last assignment datetime
                datetime now = datetime.now();
                ag.Last_Assignment__c = now;
                ag.Millisecond__c = now.millisecondGMT();
                
                //update only latest Assignment Groups per ID
                if (latestAGDateTime.containsKey(ag.id)) {
                    if(latestAGDateTime.get(ag.id) < now) {
                        updateAssignmentGroups.put(ag.id, ag);
                        latestAGDateTime.put(ag.id, now);
                    }
                } else {
                    updateAssignmentGroups.put(ag.id, ag);
                    latestAGDateTime.put(ag.id,now);
                }
                
                idx++;
            }
        }
        //Map --> List/Array for DML update
        List<Assignment_Groups__c> updateAG = new List<Assignment_Groups__c>();
        for (Id agId : updateAssignmentGroups.keySet()) {
            updateAG.add(updateAssignmentGroups.get(agId));
        }
    
        System.debug('>>>>>Update Assignment Groups: '+updateAG);   
        
        //
        //Update last assignment for Assignment Group in batch
        //
        if (updateAG.size()>0) {
            try {
                update updateAG;
            } catch (Exception e){
                for (Integer i : queueIds.keySet())
                {
                    Trigger.new[i].addError('ERROR: Could not update Assignment Group records ' + ' DETAIL: '+e.getMessage());  
                }
            }
        }
    }

 

Can a custom componenet inheret the controller from the page the controller is embeded in?

Hi,

I see with versions 20.0+ you can get access to the Report object.  What I'm not finding is whether you can then get the Report result in Apex... or rather attach the rendered Report in email (in Apex.)  

Would that be too good? or am I just missing something simple?

 

In the past I've had to construct custom csv files within Apex, convert to blob, and use it as an attachment.  

 

Thanks,

Tom

  • February 08, 2011
  • Like
  • 0

So I have (had) a fine Visualforce page working for the past year that suddenly doesn't work in Winter '11. 

Specifically the ajax part that rerenders some custom (Lookup to related records) picklists base on the "onchange" actionSupport attribute.

Did something change in Winter '11..?   Here's my vf code:

 

 

<apex:outputLabel value="*Locations" for="locations"/>          
<apex:selectList value="{!selectedLocationOption}" size="1" id="locations">
  <apex:selectOptions value="{!dependentLocationStrings}"/> 
  <apex:actionSupport event="onchange" rerender="careers"/>          		            
</apex:selectList> 

 

I'm able to get the proper results back if I keep hitting the "Send" button with missing form criteria (like First Name) so that my custom form validation fails (on purpose.)  But previously (Oct.'09 through last week) this just worked based on user selection and onchange event.

I've replicated the faulty behavior in FF, Safari, Chrome, and IE 6.

 

 

 

  • October 12, 2010
  • Like
  • 0

Anyone know if SOQL or SOSL is available for SFDC Content and Knowledge/Articles objects?

Upon some quick research, it doesn't seem like it...

 

I'm thinking of trying to build a custom single seach mechanism (that searches Content and Knowledge.)  However it needs to be available to portal users... so the new Global Search will not work,, hence the custom..

 

Thanks

  • October 04, 2010
  • Like
  • 0

Hi,

 

We have some triggers on some object X, and then there are a couple Field Update Workflows on the same object that run after the triggers. These Workflows cause the same triggers to fire again because they update object X (as a result of Field Update). What I want to do is prevent this from happening. Is there a way to queue triggers to run after Workflows? An alternative method is perhaps using an intermediary static class to keep track of the triggers that have already run, but then I don't know if this class can keep its state after the Workflows start running.

 

Any help is appreciated!!

  • August 03, 2010
  • Like
  • 0

Hi,

How do you send an email notification from Apex code? Please advice.

 

thanks

 

  • August 02, 2010
  • Like
  • 0

I noticed you can only schedule reports to email to "me" or an existing user. Is there anyway through apex to have it send to a contact?

Hi there,

 

I have a custom object called Job and I created a custom view in visualforce for that object and that is the view that I am using when I go to view a job record.  Now I have another visualforce page where I am listing all the Jobs. When the user clicks a job on that list I am also taking them to the same visualforce page that I created above for the job. I have a back button on the visualforce page. What I want to do is when I click the back button I want to go back to the return URL where it came from. So if I go to the job visual force page from the visualforce page that I created to list all jobs then I should go there. If I go to the job record through a contact(contact is related to job), then I want to go to the contact page or what ever page that I came from. Is there a way to get the return URL in salesforce? How would you approach this? Thanks.

 

Sanch.

  • June 18, 2010
  • Like
  • 0
Does anyone know of a way, either through url query parameters or some other mechanism, to display the Salesforce Content Detail screen by itself?  Basically I want to take away the sidebar and header and just have the detail screen for an individual content item.  The goal of this would be to display the item in an iframe on a Visualforce page.  Thanks for any insight.  I have the page working but want to hide the unnecessary parts and show only the detail.
  • March 03, 2010
  • Like
  • 0
I have an approval process that manages the state of a custom object.  When complete, I stamp an 'Approved Amount' with a value as part of my approval step actions.  I have a workflow rule that is intended to set the date that the budget updated, when and if it was updated after originally being set.  My workflow rule works fine if I manually change the fields that the workflow formula evaluates to true.  BUT when I try to let the approval process automate this, the workflow rule is not fired.  what gives?
  • March 19, 2009
  • Like
  • 0
Hi experts,
I found a Salesforce object named OpportunityContactRole by using the IDE (Eclipse) and I want to add a new trigger for this object but I got the following Error message when try to save the new created trigger:
    Save error: SObject type does not allow triggers: OpportunityContactRole
I really need to add the special processing to this object before updating, do any experts have any idea how to fix this issue?
Best regards!
Boi Hue


Message Edited by boihue on 12-09-2008 11:02 AM

Message Edited by boihue on 12-09-2008 11:02 AM
  • December 09, 2008
  • Like
  • 0