• CW83
  • NEWBIE
  • 25 Points
  • Member since 2013
  • Technology Supervisor
  • ProEdit, Inc


  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 8
    Replies
I have a request that came to me from an end user.  They are asking if it is possible when they create an activity in the publisher/quick action in the desktop if they can also attach a file to the activity that is created, ie. Call Notes. I know I could do it with a flow but I was trying to utlize publisher actions.  Would a VF page as a quick action work?  If so where would I start?  Any help is apprectiated 
  • April 29, 2015
  • Like
  • 0
We had a developer write an apex plugin to use in a flow but he didn't write any test for code and now my overall code coverage is less than 75% so I can't deploy anything via a changeset.  Below is the code.  Any help is appreciated.

global class mLSendEmail implements Process.Plugin {
    
    global Process.PluginResult invoke(Process.PluginRequest request) { 
        
        // Get the subject of the Chatter post from the flowgj
        //String emailS = (String) request.inputParameters.get('emailListString');
        String campaignId = (String) request.inputParameters.get('campaignId');
        String tempId = (String) request.inputParameters.get('emailTempId');
        //system.debug(idS);
        String userIdVar = UserInfo.getUserId();
        //List<String> emailList = emailS.split(', ');
        
        User userObject = [SELECT Name, Email
                           FROM User
                           WHERE Id = :userIdVar.left(15)
                           LIMIT 1]; //(String) request.inputParameters.get('userName');
        
        List<CampaignMember> test = [SELECT ContactId, CampaignId
                                     FROM CampaignMember
                                     WHERE CampaignId = :campaignId];
        
        List<Contact> contacts = [SELECT Id, Name, Email 
                                  FROM Contact 
                                  WHERE Id IN (SELECT ContactId 
                                               FROM CampaignMember 
                                               WHERE CampaignId = :campaignId AND ContactId != null)
                                  ];
        
        List<Lead> leads = [SELECT Id, Name, Email 
                            FROM Lead
                            WHERE Id IN (SELECT LeadId 
                                         FROM CampaignMember 
                                         WHERE CampaignId = :campaignId AND LeadId != null)
                            ];
        system.debug('EMAIL TEMPLATE ID: ' + tempId);
        system.debug('VALUE OF CONTACTS: ' + contacts);
        List<Messaging.SingleEmailMessage> mails = 
  new List<Messaging.SingleEmailMessage>();
        if (!contacts.isEmpty()) {
            system.debug('mLSendEmail.cls - contacts != null');
            for (integer i = 0; i <= contacts.size()-1; i++) {
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                mail.setTemplateId(tempId);
                mail.setReplyTo(userObject.Email);
                mail.setSenderDisplayName(userObject.Name);
                mail.setTargetObjectId(contacts.get(i).Id);
                mails.add(mail);
           }
        } else if (!leads.isEmpty()) {
            system.debug('mLSendEmail.cls - leads != null');
            for (integer i = 0; i <= leads.size()-1; i++) {
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                mail.setTemplateId(tempId);
                mail.setReplyTo(userObject.Email);
                mail.setSenderDisplayName(userObject.Name);
                mail.setTargetObjectId(leads.get(i).Id);
                mails.add(mail);
            }
        } else {
            system.debug('mLSendEmail.cls - else');
        }
  Messaging.sendEmail(mails);
        
        
        
        
        // return to Flow
        Map<String,Object> result = new Map<String,Object>(); 
        return new Process.PluginResult(result); 
        
    } 
    
    global Process.PluginDescribeResult describe() { 
        Process.PluginDescribeResult result = new Process.PluginDescribeResult(); 
        result.Name = 'Marketing Email Plugin';
        result.Tag = 'ML Email';
        result.inputParameters = new 
           List<Process.PluginDescribeResult.InputParameter>{
               new Process.PluginDescribeResult.InputParameter('emailTempId',
               Process.PluginDescribeResult.ParameterType.STRING, true),
               new Process.PluginDescribeResult.InputParameter('campaignId',
               Process.PluginDescribeResult.ParameterType.STRING, true)
            };
        result.outputParameters = new 
           List<Process.PluginDescribeResult.OutputParameter>{ }; 
        return result; 
    }
}
  • March 26, 2015
  • Like
  • 0
I have a javascript button I am trying to create to update a picklist field on a custom object.  Here is the code for the button:

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}

var p = new sforce.SObject('Projects__c');
p.id = "{Projects__c.Id}";
p.Status__c = "Closed";
result = sforce.connection.update([p]);
location.reload(true);

The code is not throwing errors on the object it is just not updating the field.  The page is reloading. Anything wrong with the code?

  • January 06, 2014
  • Like
  • 2

Here is the error I am getting:

Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: INACTIVE_OWNER_OR_USER, operation performed with inactive user: []", Failure Stack Trace: "Class.ChatterAnswers.createAccount: line 4, column 1 Class.ChatterAnswersCreateAccountTest.validateAccountCreation: line 10, column 1"

I am stumped.  I was able to validate and deploy from my dev sandbox to my UAT sandbox but now I get this error in production when I go to validate.   

I looked to see if I had any assignment rules that were trying to assign to an inactive user.  I also looked to make sure I didn't have any inactive users that are Chatter Answers users.  

Any ideas?

  • December 14, 2013
  • Like
  • 0

I have built a VF page to extend the use of the Mass Edit and Mass Update App from the Force.com Labs to a custom object.  My dilemma is I can't get the table to sort my the "Job Ticket Name"  I have built a "sortExtension" controller, but I don't think that is going to work.  Below is the code for the VF page and the controller. I also don't know if sorting this is even possible since it is input fields.   Any help is greatly appreciated.

 

VF Page

 

<apex:page standardController="Job_Ticket__c" extensions="sortExtension" recordSetVar="unused" sidebar="false">

<!-- for this page to work with a specific custom object, change standController="entityname" to custom object api name  
    For example, if custom object name is Warehouse__c, change first part of the first line to standardController="warehouse__c" -->

    
<apex:includeScript value="{!$Resource.UtilJS}" />
<apex:form >
<apex:pageBlock >
<apex:pageMessages />
<apex:pageBlock >
Note: All modifications made on the page will be lost if Return button is clicked without clicking the Save button first. 
</apex:pageBlock>
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Return" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!selected}" var="a" id="table">
<apex:column headerValue="Job Ticket Name">
<apex:inputField value="{!a.name}"/>
</apex:column>
<apex:column headerValue="Estimated Start Date">
<apex:inputField value="{!a.Estimated_Start_Date__c}"/>
</apex:column>
<apex:column headerValue="Estimated Hours to Complete">
<apex:inputField value="{!a.Estimated_Hours_to_Complete__c}"/>
</apex:column>
<apex:column headerValue="Estimated Completion Date">
<apex:inputField value="{!a.Estimated_Completion_Date__c}"/>
</apex:column>
<apex:column headerValue="Estimated Resume Date">
<apex:inputField value="{!a.Estimated_Resume_Date__c}"/>
</apex:column>
<apex:column headerValue="Actual Completion Date">
<apex:inputField value="{!a.Actual_date_of_completion__c}"/>
</apex:column>
<apex:column headerValue="Actual Hours to Complete">
<apex:inputField value="{!a.Actual_hours_to_complete__c}"/>
</apex:column>
<apex:column headerValue="Actual Resume Date">
<apex:inputField value="{!a.Actual_Resume_Date__c}"/>
</apex:column>
<apex:column headerValue="Actual Start Date">
<apex:inputField value="{!a.Actual_Start_Date__c}"/>
</apex:column>
<apex:column headerValue="Resource Assigned">
<apex:inputField value="{!a.Resource_Assigned__c}"/>
</apex:column>
<apex:column headerValue="Task Description">
<apex:inputField value="{!a.Task_Description__c}"/>
</apex:column>
<apex:column headerValue="Ticket Status">
<apex:inputField value="{!a.Ticket_Status__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

Controller

 

<apex:component >
 public class sortExtension{

public Job_Ticket__c Job Ticket;
public ApexPages.StandardController controller {get; set;}
{
public List<Job_Ticket__c> Job Ticket; public sortExtension (ApexPages.Standardcontroller c)
</Job_Ticket__c>
}
{
this.controller = c; Job Ticket = (Job_Ticket__c)Controller.getRecord(); }
public Job_Ticket__c [ ] getUnitList()
Name = ([Select Name,Estimated_Start_Date__c,Estimated_Hours_to_Complete__c,Estimated_Completion_Date__c,Estimated_Resume_Date__c,Actual_date_of_completion__c,Actual_hours_to_complete__c,Actual_Resume_Date__c,Actual_Start_Date__c,Resource_Assigned__c,Task_Description__c,Ticket_Status__c from Job_Ticket__c Where Job_Ticket__c.Name__r = :TC.id ORDER BY Name]);
return Name;}
</apex:component>
                                

 

  • March 20, 2013
  • Like
  • 0
I have a javascript button I am trying to create to update a picklist field on a custom object.  Here is the code for the button:

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}

var p = new sforce.SObject('Projects__c');
p.id = "{Projects__c.Id}";
p.Status__c = "Closed";
result = sforce.connection.update([p]);
location.reload(true);

The code is not throwing errors on the object it is just not updating the field.  The page is reloading. Anything wrong with the code?

  • January 06, 2014
  • Like
  • 2
We had a developer write an apex plugin to use in a flow but he didn't write any test for code and now my overall code coverage is less than 75% so I can't deploy anything via a changeset.  Below is the code.  Any help is appreciated.

global class mLSendEmail implements Process.Plugin {
    
    global Process.PluginResult invoke(Process.PluginRequest request) { 
        
        // Get the subject of the Chatter post from the flowgj
        //String emailS = (String) request.inputParameters.get('emailListString');
        String campaignId = (String) request.inputParameters.get('campaignId');
        String tempId = (String) request.inputParameters.get('emailTempId');
        //system.debug(idS);
        String userIdVar = UserInfo.getUserId();
        //List<String> emailList = emailS.split(', ');
        
        User userObject = [SELECT Name, Email
                           FROM User
                           WHERE Id = :userIdVar.left(15)
                           LIMIT 1]; //(String) request.inputParameters.get('userName');
        
        List<CampaignMember> test = [SELECT ContactId, CampaignId
                                     FROM CampaignMember
                                     WHERE CampaignId = :campaignId];
        
        List<Contact> contacts = [SELECT Id, Name, Email 
                                  FROM Contact 
                                  WHERE Id IN (SELECT ContactId 
                                               FROM CampaignMember 
                                               WHERE CampaignId = :campaignId AND ContactId != null)
                                  ];
        
        List<Lead> leads = [SELECT Id, Name, Email 
                            FROM Lead
                            WHERE Id IN (SELECT LeadId 
                                         FROM CampaignMember 
                                         WHERE CampaignId = :campaignId AND LeadId != null)
                            ];
        system.debug('EMAIL TEMPLATE ID: ' + tempId);
        system.debug('VALUE OF CONTACTS: ' + contacts);
        List<Messaging.SingleEmailMessage> mails = 
  new List<Messaging.SingleEmailMessage>();
        if (!contacts.isEmpty()) {
            system.debug('mLSendEmail.cls - contacts != null');
            for (integer i = 0; i <= contacts.size()-1; i++) {
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                mail.setTemplateId(tempId);
                mail.setReplyTo(userObject.Email);
                mail.setSenderDisplayName(userObject.Name);
                mail.setTargetObjectId(contacts.get(i).Id);
                mails.add(mail);
           }
        } else if (!leads.isEmpty()) {
            system.debug('mLSendEmail.cls - leads != null');
            for (integer i = 0; i <= leads.size()-1; i++) {
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                mail.setTemplateId(tempId);
                mail.setReplyTo(userObject.Email);
                mail.setSenderDisplayName(userObject.Name);
                mail.setTargetObjectId(leads.get(i).Id);
                mails.add(mail);
            }
        } else {
            system.debug('mLSendEmail.cls - else');
        }
  Messaging.sendEmail(mails);
        
        
        
        
        // return to Flow
        Map<String,Object> result = new Map<String,Object>(); 
        return new Process.PluginResult(result); 
        
    } 
    
    global Process.PluginDescribeResult describe() { 
        Process.PluginDescribeResult result = new Process.PluginDescribeResult(); 
        result.Name = 'Marketing Email Plugin';
        result.Tag = 'ML Email';
        result.inputParameters = new 
           List<Process.PluginDescribeResult.InputParameter>{
               new Process.PluginDescribeResult.InputParameter('emailTempId',
               Process.PluginDescribeResult.ParameterType.STRING, true),
               new Process.PluginDescribeResult.InputParameter('campaignId',
               Process.PluginDescribeResult.ParameterType.STRING, true)
            };
        result.outputParameters = new 
           List<Process.PluginDescribeResult.OutputParameter>{ }; 
        return result; 
    }
}
  • March 26, 2015
  • Like
  • 0
I have a javascript button I am trying to create to update a picklist field on a custom object.  Here is the code for the button:

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}

var p = new sforce.SObject('Projects__c');
p.id = "{Projects__c.Id}";
p.Status__c = "Closed";
result = sforce.connection.update([p]);
location.reload(true);

The code is not throwing errors on the object it is just not updating the field.  The page is reloading. Anything wrong with the code?

  • January 06, 2014
  • Like
  • 2

Here is the error I am getting:

Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: INACTIVE_OWNER_OR_USER, operation performed with inactive user: []", Failure Stack Trace: "Class.ChatterAnswers.createAccount: line 4, column 1 Class.ChatterAnswersCreateAccountTest.validateAccountCreation: line 10, column 1"

I am stumped.  I was able to validate and deploy from my dev sandbox to my UAT sandbox but now I get this error in production when I go to validate.   

I looked to see if I had any assignment rules that were trying to assign to an inactive user.  I also looked to make sure I didn't have any inactive users that are Chatter Answers users.  

Any ideas?

  • December 14, 2013
  • Like
  • 0

I've set up the Action Plans app, (https://appexchange.salesforce.com/listingDetail?listingId=a0N30000003HcINEA0)

And following the documentation.

First up it would seem the documentation for setting up a Custom Object against the action plans is a bit out of date, but I can work around the slight differences there I believe.

 

However, I'm getting the following error when running tests. 

Class.ActionPlansBatchBuilderTest.runBatchException: line 316, column 1.

 

I thought this was down to some changes I had made being incorrect so I ran all tests on production. They passed.

I then refreshed the Sandbox, and once ready ran the tests there. And this error comes up immediately. 

 

Has anyone else encountered this problem with Action Plans, and found a work around?