Questions relating to Apex, the native programming language for the Force.com platform. Use it for general questions on syntax, errors, constructs, and rules of use. Most questions should include a code *excerpt* to help answerers understand specifically what has gone wrong or why you need help.

learn more… | top users | synonyms (1)

0
votes
0answers
3 views

Task email notofications

If we assign a task to someone else, we can get an automated notice when the task is completed. For that i have written one trigger mentioned below that trigger is working fine but email is being ...
0
votes
2answers
10 views

How can I check if a PICKLIST value is not selected?

for(Account a : accounts) { noOfOpp = a.Opportunities.size(); if( isEmpty(a.Client_Account_Status_Override__c) == true ) { if(noOfActiveOpp > 0) { ...
0
votes
1answer
20 views

Upload file linked with Opportunity record

I want to create VF custom page to upload files, which are bigger than 25mb, so i can't use Attachments. I have found out, that when i upload file from "Files" tab, i can query it by SELECT id, ...
0
votes
2answers
25 views

How to pass an array of a class from a helper to an apex controller

I have created a class with several fields like this: public class Tier{ @AuraEnabled public String Name {get; set;} @AuraEnabled public integer Min {get; set;} ...
1
vote
1answer
17 views

How to parse XML data to JSON? How to deserialize XML to Apex class?

I Have Xml data as Follows String Data_XML = '<?xml version="1.0" encoding=""?> <book><price>100</price><Items>2</Items> </book>'; I wanted to deserialize ...
0
votes
0answers
8 views

Merging Attachments in Salesforce into a single attachment - is this possible natively?

I'm looking into merging multiple attachments (.pdfs) into a single attachment. The research I have done so far suggests that there is no native way to achieve this in Apex. ...
0
votes
1answer
20 views

Tree Structure Creation with Master Detail relationship Apex

I wanted to create tree structure from two custom objects with master detail relationship. Head is my Parent custom object and member_child is my child custom object with childname__c as field. I am ...
0
votes
0answers
25 views

How to implement pagination here?

This is controller where I have queried for listview with out using setFilterId method and I am getting the records according to listview values but pagination is not working public with sharing ...
0
votes
0answers
8 views

"automate generation of a badge when certain criteria are met on opportunity [on hold]

In order to achieve "automate generation of a badge when certain criteria are met on opportunity". So, For this we have created a flow and calls tht in a process builder but now its not working ...
0
votes
2answers
23 views

How to test Database.query

We have our managed package and we need to install in another org. And there are many custom fields which already exist there. So we cannot create the custom field in our org because it will cause the ...
0
votes
1answer
25 views

Image selection on VF Page

I have a 4 step wizard displaying images on visualforce page. I have created a text rich field on product with family as "t1", "t2", "t3", "t4" where I store images. I have to display images to my ...
2
votes
0answers
21 views

Can not insert FeedItem through apexrest

When trying to create a FeedItem through the ApexRest I'm always getting the following error: [{"errorCode":"APEX_ERROR","message":"System.DmlException: Insert failed. First exception on row 0; ...
1
vote
1answer
22 views

Approve/Reject many Records at once via Apex

I have an idea of approving/rejecting multiple records via apex. I read from https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_process_example.htm and I was able to ...
0
votes
1answer
23 views

Showing feedback message using Visuaforce component and and Apex

Scenario: we have an app installed in Salesforce for uploading files (the maximum limit is now 1gb). While uplaoding one file or multiple files the script gives the size and it needs to compare it to ...
3
votes
1answer
20 views

Schema.SobjectField Access Changed in API v34.0 (Summer '15)

While I was working on a Visualforce page which has some similar functionality to another page that has already been developed in the past into one of my other orgs, I decided to re-use the same code ...
1
vote
0answers
19 views

Assignment rule always auto fire with no reason

I got a project which needed to setup an public community as an endpoint to receive JSON messages (URL post method). My community home page got a restful apex class to receive message and process it ...
0
votes
1answer
16 views

Live Chat error message “Session required but was invalid or not found”

I trying to develop an apex function to connect with my Org live agent based on Salesforce official guide. apex function connect with live agent got 2 main step as following: Create a Live Agent ...
2
votes
1answer
19 views

Would updating children records at the same time cause “UNABLE_TO_LOCK_ROW” error? How can I avoid this?

I have 3 objects with the below relationship: One Account(Master) Opportunity(Detail) Custom__c(Parent) (lookup on opportunity) Opportunity(Child) Here's the scenario: I have 1 ...
-1
votes
1answer
24 views

Marketing Cloud API via Apex : persistant 401

I use my id & secret to obtain an access token but now matter what endpoint I try per the Getting Started I still get System.HttpResponse[Status=Unauthorized, StatusCode=401] ... String ...
-1
votes
1answer
17 views

Test class for a pagereference method

I am trying to test a logic in my extension. I have three boolean variable(I am setting them as false in constructor). In my method displayButton() , if all three boolean value are true then I set a ...
2
votes
0answers
9 views

Apex Page with analytics:reportChart as part of Managed Package

I want to deploy a Apex Page that references a Report with analytics:reportChart in a Managed Package. The Report is also included in the Managed Package. This issues arrises when the Apex Page ...
0
votes
0answers
21 views

How do I save checkboxes on a visualforce page?

I have designed a visualforce page that has checkboxes. I need to save those checkboxes when they are checked or unchecked. I would like the action of checking the box to save the new value. Does ...
2
votes
1answer
31 views

How to enabled DB as an external object in Heroku

I'm new to Heroku and I'm trying to wrap my head around with it and I have seen that in demo here talks about the exposing the services in Heroku and expose your services like this: ...
3
votes
1answer
15 views

“Expression cannot be assigned at line X” - Trying to incrementally increase quantity of Decimal value in an <Id,Decimal> map in a for() loop

Scenario: We have a quoting system with a child object called zqu__QuoteCharge__c that acts as the individual line items on the quote. zqu__QuoteCharge__c is also the child of ...
-1
votes
1answer
25 views

Why am I getting the System.DmlException error when running my test class

I am running the test class below and it keeps on giving me the error.Would appreciate your help on this: Here the error message Error Message System.DmlException: Update failed. First exception ...
1
vote
2answers
24 views

calculate the dates for a given months and day number

I have a function having 3 input startdate, dayofmonth and monthcount. I want to store all the dates in a List<Date> which start from startdate and after every given monthcount add the ...
2
votes
0answers
14 views

Is there a trigger I can use to catch changes to a user's e-mail signature?

I'm trying to write an Apex trigger that fires when a user changes his or her e-mail signature through Personal Setup -> Email -> My Email Settings. Because the signature is stored in User.Signature, ...
0
votes
0answers
11 views

Real time Data -Polling service Vs Outbound Messeges [on hold]

We have full sandbox environment.We are integrating information from SQL SERVER-SFDC.Then We need to Perform real time integration of Forecast on it. As I understand it,there are 2 options here: ...
1
vote
0answers
9 views

Assign an account to an Enterprise Territory in Apex [on hold]

Is there a way to assign an account to a territory2 (Enterprise Territory Managment) in apex?
1
vote
1answer
29 views

Get the specified child relationship Name from Parent

I have a VF component where I am trying to get related list(child) of any record( say Account, depends on the value I give in my VF Page). I have two attributes in my VF component , objectvar- which ...
0
votes
0answers
12 views

Owner not getting mapped to the created record

A Visualforce page reads param id of a custom object CustomObjA__c and creates a new record of CustomObjB__c by mapping the required fields from A to B. It also maps the owner of record A to B. After ...
1
vote
1answer
20 views

calculate EndDate based on only weekdays

I have a function which takes input as startDate and return the endDate where endDate is Date after 100 days excluding weekends. That is only weekdays are counted and not the weekends in the 100 days ...
3
votes
2answers
110 views

How can we upsert a list of lists of accounts

I want to update list of list of account. I am getting list of accounts from many sources, now i want to update them. list<list<sObject>> la=new list<list<sObject>>(); ...
0
votes
0answers
14 views

Unable to convert value 'userAmount' to type 'Integer' for attribute 'maximum'

I am trying to set a visualforce gauge chart to have the maximum value be a currency field from the user record. I can get the field: Decimal userAmount = [Select ISO_Goal__c From User Where Id ...
0
votes
0answers
11 views

Bypass error rule in controller

I have a error manager rule in controller at quote line item level. Scenario is whenever a particular product 'X' is added by the sales manager ... dates field should be filled in. But if the same ...
0
votes
1answer
6 views

delimite Width in selectCheckboxes tag

I have a problem with a width. The limit is 500px and if the list has a lot of options the result is like this: http://screencast.com/t/84RaW9kA8vHf I need to delimit the width to print this and if ...
1
vote
2answers
26 views

Mixed DML operation error [duplicate]

I am facing Mixed DML error in the following case: static testmethod void method1() { User u1 = DataFactory.createUser('testUser','test@user.com','permissionSetAPIname'); Obj1 rec1 = ...
0
votes
1answer
25 views

null pointer exception in page please help

I am getting this error when I press the save2 command button in the plus sign Attempt to de-reference a null object Error is in expression '{!submitLead}' in page permissionsinspector: ...
0
votes
1answer
18 views

formula field to count record weekly bases

I want to create one formula field, Which count record on weekly basis, for Exmpl, Cout__c(Formula field), There is one custom field PAckage_count_c, This field count my all packages using ...
0
votes
1answer
7 views

Last trailing blank PDF page gets added, need to remove

I have below last element and trying to remove the trailing blank pdf page added. It is not working. Can someone please let me know how to deal with it? Apex Page Last element .....<td ...
0
votes
0answers
13 views

Can we enable orderSetting using apex code? [on hold]

If yes please guide me how to enable Order Setting using apex code.
1
vote
1answer
17 views

Approaches for Add-On Package on top of Main Managed Package?

Lets say I've a free app on AppExchange (ie managed package) which provides end to end functionality and works great for most customers. Now I'm planning to build add-on logic which will provide ...
1
vote
1answer
133 views

How to search for a string in a list of strings?

I'm currently programming some pretty random things in my developer edition to try and get some practice in until my company gives me more apex projects. In my most recent project, I wanted to assign ...
1
vote
1answer
22 views

How to get child record value from parent in AJAX toolkit?

I have onclick javascript code: var a = sforce.connection.query("select Name,Net_Price__c,(select Name,Net_Price__c,Price_HT__c from Services__r) from Rfleet_Car_Set__c where id ...
0
votes
0answers
9 views

Export to excel having cache issues

There is an odd issue with catching data to display on the Visualforce page which is used for exporting. The purpose of this function is to list up certain Cases - which then will be Exported to an ...
3
votes
0answers
11 views

How to convert inline images from Email-To-Case to Attachments?

I came across this question from reddit.com/r/salesforce. We are currently running at 98% of our 22gb data usage and we have worked out that this is caused because of customers and our ...
1
vote
1answer
14 views

Convert PST to current loggedin user locale time

I have a datetime field that is populated by the user in pst timezone.I want to convert this field to the local timezone of the lead owner.How can i achieve this?I have tried this so far i am getting ...
1
vote
1answer
22 views

how to get listview query by passing the listview Id?

here is the class: public with sharing class Paginationmin1 { public String listFilterId {get; set;} Public Integer noOfRecords {get; set;} Public Integer size {get; set;} //public ...
2
votes
1answer
14 views

Help with Test Classes for Apex Classes

I am having trouble with getting one of the Classes to get Code Coverage. Below is the Code: public class Match { @TestVisible public List<Common> Common {get; set;} ...
0
votes
1answer
19 views

Regarding apex class to Test Class

I have A Given Sample Apex Code @HttpGet global static String doGet(){ RestRequest req = RestContext.request; RestResponse res = RestContext.response; try{ ...