• GarryP
  • SMARTIE
  • 500 Points
  • Member since 2013
  • Independent Salesforce Developer
  • Independent


  • Chatter
    Feed
  • 15
    Best Answers
  • 0
    Likes Received
  • 6
    Likes Given
  • 0
    Questions
  • 93
    Replies

I have facing an error when I use an aggregateresult inside the execute method of a Batch Class.

I have being reviewing old post and I have read the solution provided here https://help.salesforce.com/apex/HTViewSolution?urlname=Aggregate-queries-and-Batch-Apex&language=en_US
but in that solution, the problem is in the start , not in the execute.

My batch class is like this :
global class BatchClass implements Database.Batchable<Sobject> {

global Database.QueryLocator start(Database.BatchableContext ctx) {
        String query = 'select a lot of records based in Ids and Dates';
        return Database.getQueryLocator(query);
    }
    global void execute(Database.BatchableContext ctx, List<Sobject> sObjects) {
    for(AggregateResult result : [select field1__c,field2__c, sum(Net_Revenue__c) r from Revenue__c where Type__c = 'C' where :condition group by Corporate_Account__c, Year_Month__c]){
            revenues.get((Id)result.get('c')).addRevenue((String)result.get('m'), (Decimal)result.get('r'));
        }

When I execute the class, I get this.

First error: Aggregate query does not support queryMore(), use LIMIT to restrict the results to a single batch

Any idea on how to resolve this?

Thanks
      
    }


}

Hi I have small requirement  i have 2 text fields Textfield1 and fTextield2 now Textfield1 consists praveen_o6 and Textfield2 consists _o6 now output should come in the other field as praveen because it should trim the values from field1 since the value matches the field 2 

is there possibility 
Name &" "& Geo_Suffix__c this is existing formula which i am using now to combine both fields 1 & 2 but i need to compare and trim the value 
show it in field3 
Input: Territory Name: AMER_PS_PBU2_AD_SI1_06

Geo Suffix: 06

Out put: AMER_PS_PBU2_AD_SI1
I am trying to setup the OAuth process to get the access_token, specifically in PHP using this example (http://developer.force.com/cookbook/recipe/interact-with-the-forcecom-rest-api-from-php). However, I don't know how to avoid the "Allow Access" page that shows up, I would like to be autimatically allowed so the application can continue and get the access_token... It would be a pain to have to manually allow access on every system I am planning on implementing this integration.. What am I missing?
I would like to create a button on an opportunity detail page. The buttom will lead to a page to update fields, which the fields are sitting on the opportunity detail page and the account detail page. 

I do not know where to start on this. Help/direction will be much appreciated. 
User-added image
I want to show the reuslt with the percentage, what should I do?
Hi,

We have to create a lightning page that has a set of checkboxes that a user is allowed to set to true or false. There is also a button that based on the checkboxes that are selected, it will perform some action through an apex classes. A sample scenario is below. What is the recommended way to accomplish this as i am trying to optimize and keep things simple?

Example scenario (assume 20 checkboxes exists)
  1. checkbox1=true
  2. checkbox2=true
  3. checkbox3=true
  4. checkbox10=true
  5. all other checkboxes are false
  6. On click of a button, the input should be passed to an apex class which will take the input and run some action based on what is selected as true
  • December 06, 2016
  • Like
  • 0
Hi,

Help needed in removing the text which is present after hyphen(--) from a TexBody (EmailMessage field). So my request is to copy only the new Email to case comment.

for Example:

Hello,

This is an example.

--- Original Message--

Previous Email Threads


Copy only "Hello,

This is an example."  to the case comment field.

Kindly please let me know a possible solution to acheive this.

Thanks in Advance.

Regards,
Sathish 
Hi, 
 I overrode the "Createpdf" button on quote page with a custom VF page (Quotecustom). I would like to create another button on quote page that lets me save that pdf as an attachment to the QuotePDF related list. 
What are the steps to do this? 
I know I need a controller that looks something like this: 
public class attachPDFToquote {
	
	private final quote q; //quote object
	
	//constructor
	public attachPDFToquote(ApexPages.StandardController standardPageController) {
		q = (Quote)standardPageController.getRecord(); //instantiate the quote object for the current record
	}
	
	//method called from the Visualforce's action attribute
	public PageReference attachPDF() {
		//generate and attach the PDF document
		PageReference pdfPage = Page.quotecustom; //create a page reference to quote custom Visualforce page
		Blob pdfBlob = pdfPage.getContent(); //get the output of the page, as displayed to a user in a browser
		Attachment attach = new Attachment(parentId = q.Id, Name = 'pdfAttachmentDemo.pdf', body = pdfBlob); //create the attachment object
		insert attach; //insert the attachment
		//redirect the user
		PageReference pageWhereWeWantToGo = new ApexPages.StandardController(q).view(); //we want to redirect the User back to the quote detail page
		pageWhereWeWantToGo.setRedirect(true); //indicate that the redirect should be performed on the client side
		return pageWhereWeWantToGo; //send the User on their way
	}

}
Im confused about the next step...do I have to create another seperate VF page or add the controller as an "extension" to my Quotecustom VF page. Please excuse my misunderstandings as Im new to this. 

THanks.
 
  • December 05, 2016
  • Like
  • 1
Hello, new developer here. I want to make a few changes aesthetic changes to my VF page

i would like to hide the field name titled - "Note". Since i have a title that enlightens the user on what the VF page is for, the "Note" label is unnecessary.

Also, I want to shift the text box left so it sits flush with the title and Save button. I already have a style to make the text box larger so i know i will need a StyleClass. Wondering if i can get some help to have the style both shift left and have a width of 400

Below is a picture of the VF page (marked with the 2 things i want done) and the code that goes with it 

User-added image

<apex:page standardController="Notes_for_the_Day__c">
<apex:form >
  <apex:Pageblock Title="Notes on the Day">
  <apex:pageBlockSection columns="1">
  <apex:inputField Value="{!Notes_for_the_Day__c.Note__c}"
 style="height:100px;width:400px;"/>
  <apex:commandButton action="{!save}" value="save"/>
  </apex:pageBlockSection>
  </apex:Pageblock>
  </apex:form>

Thank you in adnvance
 
Our customer support team needs to know immediately if a contact they've email that's related to a case they're working gets a bounced back email notification.   I'd like to have the case status changed to 'Bounced Email' if this happens.  I think apex is needed but anyone have any thoughts?
Hi,
while embedded VF page with custom object page layout that time VF fields are  not showing, in visulaforce page all fields are showing and i am able to save value also but after add that VF page in custom object page layout all fields are hidding. 
Please help me

Thanks & Regards
Bhushan Singh
Hi,

We have a VF page that has a button which is supposed to trigger some action. How would we create a button on the VF page that will call a future class once clicked?

The objective is to click the button, then initiate a future class to perform some action that will run in the background while the user is able to proceed. 
  • December 04, 2016
  • Like
  • 0
I have a Salesforce javascript List-View Button that I am trying to compile but I keep encountering a Syntax Error. The Code area highlights the '=' in this Statement:
var dayOfWeekVal = {!MOD( ({!TODAY()} - {!DATE(1900,1,8)} ), 7)};

This variable precedes a switch statement. I was able to successfully compile previously, but I had to introduce Salesforce Function-specific syntax.

Does anything in this line of code look syntatically incorrect?

Here is the entire Button code block for context:
 
{!REQUIRESCRIPT("/soap/ajax/36.0/connection.js")} 

var recordIds = {!GETRECORDIDS( $ObjectType.Creative_ID__c )};
var updatedTrackers = [];

//create variable to store the new Creative Start Date
var broadcastCrtvStart;

if (recordIds[0] == null) { 
	alert("Please select at least one Creative ID.") } 
else { 

	var dayOfWeekVal = {!MOD( ({!TODAY()} - {!DATE(1900,1,8)} ), 7)};

	switch( dayOfWeekVal ) {
		case 0: 
			broadcastCrtvStart = {!TODAY()} + 7;
			break;
		case 1:
			broadcastCrtvStart = {!TODAY()} + 6;
			break;
		case 2:
			broadcastCrtvStart = {!TODAY()} + 5;
			break;
		case 3:
			broadcastCrtvStart = {!TODAY()} + 4;
			break;
		case 4:
			broadcastCrtvStart = {!TODAY()} + 3;
			break;
		case 5:
			broadcastCrtvStart = {!TODAY()} + 2;
			break;
		case 6:
			broadcastCrtvStart = {!TODAY()} + 1;
		default:
			broadcastCrtvStart = {!TODAY()};
	}	

	var errors = [];


	for (var i = 0; i < recordIds.length; i++) { 
			var ctracker = new sforce.SObject("Creative_ID__c");
			ctracker.id = recordIds[i];		
			
			ctracker.Creative_Start_Date__c = broadcastCrtvStart;
			updatedTrackers.push(ctracker);
	}


	result = sforce.connection.update(updatedTrackers);

	if (result && result.length){ 
		var numFailed = 0; 
		var numSucceeded = 0;

		for(var i = 0; i < result.length; i++) {		
			var res = result[i]; 
			if (res && res.success == 'true'){ 
				numSucceeded++; 
			} else { 
				var es = res.getArray("errors"); 
				if (es.length > 0) { 
					errors.push(es[0].message); 
				} 
				numFailed++; 
				} 
			}
		} 
	if (numFailed > 0){ 
		alert("Failed: " + numFailed + "\nSucceeded: " + numSucceeded + " \n Due to: " + errors.join("\n")); 
	} else { 
		alert("Number of Creative IDs turned on: " + numSucceeded); 
		} 
	window.location.reload();
}



 
Hello Developers!

I need your help in following.
I have two objects with lookup relationship 1) Projects__c Parent and 2) Participants__c as child
Requirement: Create roll up summary on parent to count all devoted hours from child.
My trigger:
Trigger CountHours On Participants__c (After Insert, After Update, After Delete, After Undelete){
    
    List<Participants__c> Parti = New List<Participants__c>();
    Set<ID> ProjIds = New Set<ID>();
    
    if (!Trigger.isDelete)
    {
        for (Participants__c PC: Trigger.New)
        {
        ProjIds.add(PC.Project__c);
        }
    }
    else 
    { 
       for (Participants__c PC: Trigger.old)
        {
        ProjIds.add(PC.Project__c);
        }
    }
    Parti = [Select Devoted_Hours__c From Participants__c where Project__c IN: ProjIds];
    Double X = 0;
    for(Integer I = 0; I<Parti.size(); I++){
        if(Parti[I].Devoted_Hours__c != null){
            X += Parti[I].Devoted_Hours__C;
        } 
    }
    List<Projects__c> Projs = New List<Projects__c>([Select Total_Devoted_Hours__c From Projects__c Where ID IN: ProjIds]);
   if (!Trigger.isDelete){
            for(Participants__c Partici: Trigger.New){   
                for (Projects__c P: Projs){ 
                     P.Total_Devoted_Hours__c = X;
                }
            }
        }
        else {
            for(Participants__c Partici: Trigger.Old){    
                for (Projects__c P: Projs ){ 
                    P.Total_Devoted_Hours__c = X;
                }
            }
        }
    
    update Projs;
 
}

This trigger works fine for when record is inserted, updated deleted, or even undeleted but strange thing is when I update all child records from list views (using Mass Update App), all parents gets updated with the sum of devoted hours.
How?
Here is a list view of child object:
User-added image
Here is a list view of parent object
User-added image
If I update list view of child with as Mass Update, 
the parent records gets updated like this,
User-added image
 I am wondering why all of the project got updated with total of all Participants__c's devoted hours?
Thank You for the help guys..
Hello all!
I am attempting to switch the default opportunity list view in Lightning from "recent" to "my open opportunities".  I have created a VF page, and adjusted the tab to show the VF page instead of the default.  I think I'm almost there, but 2 issues.
1.  The page displayed is classic with a lightning header.  I would like it to be displayed as a lightning page.
2.  The displayed list is not "my open opportunities".
my VF page code is as follows:
<apex:page showHeader="true" tabstyle="Opportunity">
<apex:ListViews type="Opportunity" />
</apex:page>

any assistance on this is appreciated.
Order order1=new Order();
        order1.AccountId=ac.Id;
        order1.EndDate=Date.newInstance(2019,07,25);
        order1.Pricebook2Id=priceBookS.Id;
        order1.EffectiveDate=Date.newInstance(2019,07,16);
        order1.Status='In';
         order1.TotalAmount=1;
        order1.totaltransaction=1;
        //order1.Status='In';
        insert order1;

my test class is this I have validation rule that is totalamount = totaltransaction so when i am running the test it is failing because of validation rule 

But totalAmount field is not writeable and totaltransaction is rollup field 

how can I insert the TotalAmount field in testclass
Hi,

I am trying to move custom component (on click javascript button) from classic to lightning. The current classic button exceute by
1, query [Select Id, custom_field__c from casechildline__c Where caseparentId__c =: varibableId AND custom_field__c = NULL];
2, set custom_field__c = 'Some value'; for return records
3, update return records

How to achieve through lightning components? Any sample code.

Thanks in advanced!
Here is the error: System.AssertException: Assertion Failed: Expected: 0050f000008wRZYAA2, Actual: 0050f000009O7CcAAK 
Stack Trace: Class.TestRROutboundYoga.testRROutboundInsertPriority: line 29, column 1

Here is the class:
@isTest
private class TestRROutboundYoga {

//-- Tests RoundRobinLeadRoutingOutbound.trigger
    static testMethod void testRROutboundInsertPriority(){
        Profile prof = [select Id from Profile where Name = 'Outbound Sales Yoga'];
        
        //ensure existing users are not available for round robin
        List<User> existingUsers = [select Id from User where ( Profile.Name = 'Outbound Sales Yoga' ) and isActive = true and Available_for_Leads__c = true];
        for(User u : existingUsers){
            u.Available_for_Leads__c = false;
        }
        update existingUsers;
        
        User salesUsr = new User(FirstName = 'Outbound', LastName = 'Sales', Alias = 'out', UserName='test@roundrobin.com', ProfileId = prof.Id, Available_for_Leads__c = true,
                                 LanguageLocaleKey='en_US', Email='test@roundrobin.com', EmailEncodingKey='UTF-8', LocaleSidKey='en_US', TimeZoneSidKey='America/Los_Angeles');
        insert salesUsr;
        
        Test.startTest();
        Lead lead = new Lead(FirstName = 'Round', LastName = 'Robin', Company = 'Round Robin Test', Status = 'Prospect', Vertical_Industry__c = 'Yoga',
                             Email = 'test@rr.com', Phone = '4085551234', Country = 'US', Street = '123 Billing Street', City = 'Davis', State = 'CA', PostalCode = '11111',
                             Website = 'website@domain.com', Number_of_Members__c = 64);
        insert lead;
        Test.stopTest();
        
        //requery and assert lead was assigned to user and last lead assignment updated
        lead = [select Id, OwnerId, Owner.Name from Lead where Id = :lead.Id];
        salesUsr = [select Id, Last_Lead_Assignment__c from User where Id = :salesUsr.Id];
        system.assertEQUALS(lead.OwnerId,salesUsr.Id);
        system.assertEquals(salesUsr.Last_Lead_Assignment__c.Date(), system.today());
    }
    
    
    //-- Tests RoundRobinLeadRoutingOutbound.trigger
    static testMethod void testRROutboundUpdatePriority(){
        Profile prof = [select Id from Profile where Name = 'Outbound Sales Yoga'];
        
        //ensure existing users are not available for round robin
        List<User> existingUsers = [select Id from User where ( Profile.Name = 'Outbound Sales Yoga' OR Profile.Name = 'Outbound Team Leader' ) and isActive = true and Available_for_Leads__c = true];
        for(User u : existingUsers){
            u.Available_for_Leads__c = false;
        }
        update existingUsers;
        
        User salesUsr = new User(FirstName = 'Outbound', LastName = 'Sales', Alias = 'inb', UserName='test@roundrobin.com', ProfileId = prof.Id, Available_for_Leads__c = true,
                                 LanguageLocaleKey='en_US', Email='test@roundrobin.com', EmailEncodingKey='UTF-8', LocaleSidKey='en_US', TimeZoneSidKey='America/Los_Angeles');
        insert salesUsr;
        
        Lead lead = new Lead(FirstName = 'Round', LastName = 'Robin', Company = 'Round Robin Test', Vertical_Industry__c = 'Yoga', Email = 'test@rr.com', Phone = '4085551234',
                             Country = 'US', Street = '123 Billing Street', City = 'Davis', State = 'CA', PostalCode = '11111', Website = 'website@domain.com', Number_of_Members__c = 64);
        insert lead;
        
        Test.startTest();
        lead.Status = 'Prospect';
        update lead;
        Test.stopTest();
        
       
       }
       }


AND HERE IS THE TRIGGER

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
trigger RoundRobinLeadRoutingOutboundYoga on Lead (before insert, before update) {
  
  try{
    //lists to hold all leads of relevant status
    List<Lead> lowLeads = new List<Lead>();
    
    //lists to hold only those leads which should be round robined
    List<Lead> roundRobinLow = new List<Lead>();
    
    Map<Id, User> userMap = new Map<Id, User>(); //map user info by Id
    //lists holding eligible users in order of lead assignment
    List<LowPrioritySort> lowUsers = new List<LowPrioritySort>(); //wrapper class for users implements compareTo on last low priority lead assignment
    List<User> mqlUsers = new List<User>();
    
    //set and list to ensure unique users to update
    Set<Id> userSet = new Set<Id>();
    List<User> userLst = new List<User>();
    
    //if trigger is insert, collect leads inserted with a relevant status
    if(trigger.isInsert){
      for(Lead lead : trigger.new){
        if(lead.Vertical_Industry__c == 'Yoga' && (lead.Status == 'Prospect') ){
          lowLeads.add(lead);
        }
      }
    }
    //if trigger is update, collect leads which have changed to a relevant status
    else if(trigger.isUpdate){
      for(Lead lead : trigger.new){
        if(trigger.oldMap.get(lead.Id).Status != lead.Status ||trigger.oldMap.get(lead.Id).Vertical_Industry__c != lead.Vertical_Industry__c ){
        if(lead.Vertical_Industry__c == 'Yoga' && (lead.Status == 'Prospect') ){
            lowLeads.add(lead);
          }
        }
      }
    }
    
    
    //if leads have been updated to any of the relevant statuses they may be eligible for round robin
    if(lowLeads.size() > 0){
      //query additional user info
      List<User> users = [select Id, ProfileId, Profile.Name, isActive, Available_for_Leads__c, Last_Lead_Assignment__c,
                Last_Low_Priority_Lead_Assignment__c from User
                order by Last_Lead_Assignment__c asc nulls first];
      
      //create a map of all users by Id
      for(User u : users){
        userMap.put(u.Id, u);
      }
      
      //assign users to list of outbound sales agents who are avail for leads
      for(User u : users){
        if( ( u.Profile.Name == 'Outbound Sales Yoga') && u.isActive == true && u.Available_for_Leads__c == true){
          lowUsers.add(new LowPrioritySort(u));
        }
      }
      
      //sort lowUsers list by last low priority lead assignments
      lowUsers.sort();
    }
      
    
    //only round robin low priority leads not already owned by outbound rep
    if(lowLeads.size() > 0){
      for(Lead lead : lowLeads){
        //if lead not already owned by outbound sales agent, add to list to round robin
        if( ( userMap.get(lead.OwnerId).Profile.Name != 'Outbound Sales Yoga') && (userMap.get(lead.OwnerId).Profile.Name != 'Inbound Sales')){
          roundRobinLow.add(lead);
        }
      }
    }
    
    /* ROUND ROBIN LOW PRIORITY LEADS */
    if(roundRobinLow.size() > 0){
      //round robin to available outbound sales agents
      if(lowUsers.size() > 0){
        Integer userIndex = 0; //initialize index
        for(Lead lead : roundRobinLow){
          //assign to current user indexed
          User currUser = lowUsers[userIndex].usr;
          lead.OwnerId = currUser.Id;
          currUser.Last_Lead_Assignment__c = system.now(); //update last lead assignment
          if(!userSet.contains(currUser.Id)){ //check if already in list
            userSet.add(currUser.Id);
            userLst.add(currUser);
          }
          userIndex++; //advance to next user
          if(userIndex >= lowUsers.size()){
            userIndex = 0; //reset index
          }
        }
      }
    }
    
    
    
    //update users if necessary
    if(userLst.size() > 0){
      update userLst;
    }
  }
  catch(Exception e){
    system.debug('EXCEPTION in RoundRobinLeadRouting.trigger: ' + e);
  }
}


Can anyone help me with fixing this line?
Hi everybody,
I am trying to use Rest API, I want to use the method User-Agent OAuth Authentication Flow. 
https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_understanding_user_agent_oauth_flow.htm

But when I use this URI: 

https://login.salesforce.com/services/oauth2/authorize?response_type=token&client_id=3MVG9CEn_O3jvv..................................v8c20JARGLpzU8n8BB&redirect_uri=https%3A%2F%2Fmail%2Egoogle%2Ecom%2Fmail%2Fu%2F1%23inbox&state=mystate

I get this error message:

error=redirect_uri_mismatch&error_description=redirect_uri%20must%20match%20configuration

Also I created a connected app and my Callback URL is:

https://mail.google.com/mail/u/1/#inbox

If I use this method Username-Password OAuth Authentication Flow:

https://login.salesforce.com/services/oauth2/token?grant_type=password&client_id=3MVG9CEn_O3jvv0xJWqiG...........R44rfMsyb1vuI4AE32pdEtN2pybLJDv8c20JARGLpzU8n8BB&client_secret=302826.......3314693&username=sto%40.com&password=svsdvvsdvvxvxcQsfsfsfszbbbhrxtxmQXtjbZoBsmMh6sYKMv

I could get the token and it is working.

Could someone help with this error?

 

Hi All,

I have created component for lightning button 'Email Team Member'. This button has ability to open outlook email whenever I click on this button. So the problem I am facing currently is when I click on this button it's opening one pop up from where I have to click again on the button.

 

See this attached pictures here!

Button 

When I click on Email Team Member button above, below screen pop - up from where i have to click again on button.

User-added image

Any help would be appreciated.

 

Thanks

Hi ,
I have a input text field to type in a input value and a custom button "Add" to add these records to a custom object.  After adding the record the record should be displayed immediately on the same page.
If I add 5 records all the 5 records should be displayed after the Add button.  If I add a 6th record now this record should be visible after the 5th record.

How to accomplish this?

Thanks
Rao
 
  • April 15, 2018
  • Like
  • 0
I am sending a Lightning Event from a component which is supposed to be received by another component.
The event is fired when clicking on a button.
I did some debugging : the event does get fired but the receiving method is not triggered.

Event :
<aura:event type="APPLICATION" description="Event template">
    <aura:attribute name="boatTypeId" type="String" />
</aura:event>

Notifier COmponent :
 
<aura:component controller="BoatSearch">
      
    <aura:registerEvent name="formSubmit" type="c:FormSubmit"/>

     <lightning:button onclick="{!c.onFormSubmit}" /> 

</aura:component>
Notifier component controller :
 
({
    onFormSubmit: function (component) {
       
        var compEvent = component.getEvent("formSubmit");
        compEvent.fire();

    }
})
Receiving component:
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes"  
                controller="BoatSearchResults"
 >

        <aura:handler name="formSubmit" event="c:FormSubmit" action="{!c.search}"/>
    
</aura:component>

Receiving component controller :
 
({
    search : function(component, event) {
        //var boatTypeId = event.getParam("message");
        helper.onSearch(component);
    }
})
The event is fired but I do not reach search() method, why?




 
public class CreateRecord
{
public static void createAccount(){
    List<Account> accList=Trigger.new;
    List<Account> accs=new List<Account>();
    for(Account a:accList){
        Account a1=new Account();
        a.Name='mbnchowdary';
        a.Site='mandalapu';
        a.Email__c='mbnchowdarysfdc@gmail.com';
        accs.add(a);
        System.debug(accs);
        
    }
    
    insert accs;

}    
    
}


<aura:component  controller="RecordInsertion">
    <ui:button label="click"  aura:id="button" press="{!c.doPerform}"/>
</aura:component>


({
    
    
               doPerform:function(component,event,helper){
               console.log('method is called');
                   var action=component.get('c.createAccount');
                       action.setParams({

            });
        $A.enqueueAction(action)
                   
                   
                   
        
        
    }
    
    
})
I have a custom object that has fields that are lookups to both an account and a contact.  Under certain conditions, when the custom object is saved it will examine the member criteria and update the account ID on the contact to be associated to the account ID on the referral object.  When I run this under an account that has admin rights it works perfectly.  When I run under any other account in the system I get the following error:

Workflow Action Failed to Trigger Flow
The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID XXXXXXXXXX. Flow error messages: &lt;b&gt;An unhandled fault has occurred in this flow&lt;/b&gt;&lt;br&gt;An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information. Contact your administrator for help. 

I found this article to try and narrow down their the flow it's failing on (I have a pretty good idea which) or *WHY* is failing.  Can't figure it out but wonder if it's an issue with changing the account for an contact for a non admin that doesn't have rights to do so.  Is that possible?  If so, how do I fix this?

https://success.salesforce.com/answers?id=9063A000000DapGQAS

The article in question doesn't seem to help, first because it's pointing at what appears to be an older version of the process editor and it only works with flash which I don't have in chrome.

Appreciate your help and guidance!
I built a lightning component from where i call to a external URL using window.location.href = 'someurl'. But i don't know if that is a good practice in Salesforce Lightning Experience. I also tried with sforce but i would need to add it through connection.js and apex.js and from the lightning component itself i can't. (Sorry for my bad english, i am not a native english speaker)

Thanks in advance :)
Not able to create a Custom object using REST API. Below is the C# code.

                dynamic account = new ExpandoObject();
                account.Name = "Custom Object";
                account.Description = "New Salesforce Integration";

                string endpoint = instanceUrl + "/services/data/v36.0/sobjects/CustomObject__c";                

                using (var httpClient = new HttpClient())
                {
                    using (var httpRequest = new HttpRequestMessage(HttpMethod.Post, endpoint))
                    {
                        httpRequest.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);

                        httpRequest.Content = new StringContent(JsonConvert.SerializeObject(account), Encoding.UTF8, "application/json");
                        using (var httpResponse = await httpClient.SendAsync(httpRequest))
                        {
                            if (httpResponse.IsSuccessStatusCode)
                            {
                                var response = await httpResponse.Content.ReadAsStringAsync();
                                var result = serializer.Deserialize<Dictionary<string, object>>(response);                               
                            }

                            string errorResult = await httpResponse.Content.ReadAsStringAsync();
                            jsonObject = serializer.Deserialize<Dictionary<string, object>>(errorResult);                           
                        }
                    }
                }

I always get error result as  "Requested object not found", since there is no custom object created yet in salesforce.
I would like to know how to create Custom Object in Salesforce using REST API.
I have written a trigger to delete records on two objects after updating on parent object.
This is how relationship
Training_Plan__c (Parent) to STM_Computation__c (Child)
Monthly_Totals__c (Parent) to STM_Computation__c (child)
After updating on Training_Plan__c records on STM_Computation__c needs to be deleted. Any Monthly_Totals__c records associated with deleted STM_Computation__c records need to be deleted as well. But my trigger delete only STM_Computation__c. It doesn't delet associated Monthly_Totals__c records.
My trigger:

trigger STMdeleteFromWithdrawal on Training_Plan__c (After update) { Set<Id> ids = Trigger.newMap.keySet(); List<Training_Plan__c> updatedTAs = [Select Id, TEC_Status__c, (select ID, STM_Date__c, Training_Plan_Withdrawal_Date__c, Monthly_Totals_Name__c from STM_Computations__r) From Training_Plan__c where Id IN :ids]; //get collection of STM computaion records to delete List<STM_Computation__c> stmToDelete = new List<STM_Computation__c>(); for (Training_Plan__c tps : updatedTAs){ String oldValue = Trigger.oldMap.get(tps.Id).TEC_Status__c; String newValue = tps.TEC_Status__c; if(oldValue != newValue){ for (STM_Computation__c stm: tps.STM_Computations__r){ if(stm.STM_Date__c>stm.Training_Plan_Withdrawal_Date__c){ stmToDelete.add(stm); } } } } //get collection of Monthly Total ids to delete set<id> mtsIds = new set<id>(); for (STM_Computation__c stms : stmToDelete){ mtsIds.add(stms.Monthly_Totals_Name__c); } List<Monthly_Totals__c> monthlyTotalsToDelete = [Select Id From Monthly_Totals__c where Id IN :mtsIds]; //Delete STM Computation records if(!stmToDelete.isEmpty()) { delete stmToDelete; } //Delete Monthly Totals records if(!monthlyTotalsToDelete.isEmpty()) { delete monthlyTotalsToDelete; } }
Hi All,

Recently I have made some changes to my Visualforce page picklist value. New picklist value is getting displayed on the preview section of the visual force page but same is not reflecting on the public site where this page is used.

Do I need to perform any other action in order to push new code changes of visual force page to the public site?

Thanks,
Pankaj Kr Pandey 
My current code is as follows(I re-wrote the first part of the URL for security):

<apex:page standardController="Account">
    <apex:pageBlock >
      <apex:outputText style="font-style:bold; font-sizje: 12pt" value="Tableau Dashboards for {0} with AD User ID {1} and Sales Rep ID {2} and Ship To # {3}.">
        <apex:param value="{!$User.Username}"/>
        <apex:param value="{!$User.ADUser__c}"/>
        <apex:param value="{!$User.BATO_Sales_Rep_ID__c}"/>
        <apex:param value="{!Account.Customer_Number__c}"/>
      </apex:outputText>    
    </apex:pageBlock> 
    
    <apex:iframe src="https://salesforce.com/embed_dashboard.php?workbook=Salesforce_Dashboard_Ship_To&view=Salesforce_Dashboard_Ship_To&user={!$User.ADUser__c}&Ship_To={!Account.Customer_Number__c}&width=1300px&height=600px" height="550px" width="1250px" scrolling="false"/>
</apex:page>


I'm trying to embed a tableau dashboard on an account page and pass parameters for filtering purposes.  The dashboard renders for my browsers, but fails in the SF1 app.  Salesforce says it's the iframe so I need a workaround, but I don't quite know how to write the code.
Hi,

I was trying to get the number of Lead records with XYZ picklist values equals particular values i.e. a table with

       coloumn 1                                  coloumn 2
row1 : ABC              ABC (i.e. count of lead records where field XYZ = A or B or C)
row2 : ACD              ACD (i.e. count of lead records where field XYZ = A or C or D)
row3 : BCD              BCD (i.e. count of lead records where field XYZ = B or C or D)

I tried to acheive this using bucketing in report but couldn't because of salesforce some limitations on bucket fields. So i  am trying to create a vf page table. Any suggestions?

Thanks a Ton! for any help.


 
Hi, I'm trying to print a search field on a Visualforce Page that allows the user to choose any account he wants. Something like that:

http://salesforce.stackexchange.com/questions/66583/create-visualforce-input-that-uses-lookup-popup
User-added image

The problem is that I could not see all the accounts because I'm reusing a Contact field (AccountId). Does anyone know any way to print a input/search field that could allow me to do this? Thank you all!
Hello Friends,

I have a requirement where I need to have a 'login' button on my VF page and upon click it should function like how it is going to work when we logged in as a user from a user record. In my VF Page I created a picklist field to display all the user records and a login button. 

Can you Please tell me how can I write the logic to login button.

please find the code below i have written:

VF Page:
<apex:page controller="ListOfUsers">
  <apex:form >
       <apex:pageBlock >
         <apex:pageBlockSection >
                      <apex:OutputPanel title="Select User">
                                 <apex:selectList size="1" multiselect="false"  >
                                          <apex:selectOptions value="{!ListOfUsers}" />
                                 </apex:selectList>
                        </apex:OutputPanel>
          </apex:pageBlockSection>
          <apex:commandButton value="Login"  />
      </apex:pageBlock>
</apex:form>
</apex:page>

Controller:
public class ListOfUsers {
List<SelectOption> Options = new List<SelectOption>();
      public List<SelectOption> getListOfUsers()
    {
                  
              
               for(User u : [select id ,Username,name from user]  )
               {
                          Options.add(new SelectOption(u.Id , u.Name));
               }
              return Options;
    }
}
I am trying to setup the OAuth process to get the access_token, specifically in PHP using this example (http://developer.force.com/cookbook/recipe/interact-with-the-forcecom-rest-api-from-php). However, I don't know how to avoid the "Allow Access" page that shows up, I would like to be autimatically allowed so the application can continue and get the access_token... It would be a pain to have to manually allow access on every system I am planning on implementing this integration.. What am I missing?
Hi, 
 I overrode the "Createpdf" button on quote page with a custom VF page (Quotecustom). I would like to create another button on quote page that lets me save that pdf as an attachment to the QuotePDF related list. 
What are the steps to do this? 
I know I need a controller that looks something like this: 
public class attachPDFToquote {
	
	private final quote q; //quote object
	
	//constructor
	public attachPDFToquote(ApexPages.StandardController standardPageController) {
		q = (Quote)standardPageController.getRecord(); //instantiate the quote object for the current record
	}
	
	//method called from the Visualforce's action attribute
	public PageReference attachPDF() {
		//generate and attach the PDF document
		PageReference pdfPage = Page.quotecustom; //create a page reference to quote custom Visualforce page
		Blob pdfBlob = pdfPage.getContent(); //get the output of the page, as displayed to a user in a browser
		Attachment attach = new Attachment(parentId = q.Id, Name = 'pdfAttachmentDemo.pdf', body = pdfBlob); //create the attachment object
		insert attach; //insert the attachment
		//redirect the user
		PageReference pageWhereWeWantToGo = new ApexPages.StandardController(q).view(); //we want to redirect the User back to the quote detail page
		pageWhereWeWantToGo.setRedirect(true); //indicate that the redirect should be performed on the client side
		return pageWhereWeWantToGo; //send the User on their way
	}

}
Im confused about the next step...do I have to create another seperate VF page or add the controller as an "extension" to my Quotecustom VF page. Please excuse my misunderstandings as Im new to this. 

THanks.
 
  • December 05, 2016
  • Like
  • 1
Our customer support team needs to know immediately if a contact they've email that's related to a case they're working gets a bounced back email notification.   I'd like to have the case status changed to 'Bounced Email' if this happens.  I think apex is needed but anyone have any thoughts?
Hello all!
I am attempting to switch the default opportunity list view in Lightning from "recent" to "my open opportunities".  I have created a VF page, and adjusted the tab to show the VF page instead of the default.  I think I'm almost there, but 2 issues.
1.  The page displayed is classic with a lightning header.  I would like it to be displayed as a lightning page.
2.  The displayed list is not "my open opportunities".
my VF page code is as follows:
<apex:page showHeader="true" tabstyle="Opportunity">
<apex:ListViews type="Opportunity" />
</apex:page>

any assistance on this is appreciated.
Hi All, 

question regarding Formula field Export. We are currently performing data cleaning in our Org and would like to see the actuall formulas behind the formula filds in order to determin if they are useful or not. What I mean is that for example if I have a formula on the Lead which pulls Owner's Division value I would actually like to see $Owner.Division 

So when I run a report/export/some tool I would see something like:

Lead Owner Division ,   Lead_Owner_Division__c,   Formula (Text) ,   $User.Division

Do you know of any such tool available or if I can actually do it via DataLoader or the Workbench? 

Thanks,
Art.

When someone takes the time/effort to repspond to your question, you should take the time/effort to either mark the question as "Solved", or post a Follow-Up with addtional information.  

 

That way people with a similar question can find the Solution without having to re-post the same question again and again. And the people who reply to your post know that the issue has been resolved and they can stop working on it.