-
ChatterFeed
-
67Best Answers
-
6Likes Received
-
0Likes Given
-
33Questions
-
341Replies
attempt to dereference a null object
Below is my Code. I am getting an error that I am attepting to dereference a null object. I am not sure how to fix it. I am very new to writtng triggers and any help would be very appriciated.
trigger LastActDate3 on Task (after insert, after update) {
Set <ID> OptyIDs = new Set <ID> ();
Set<Id> Ready4Update = new Set<Id>();
List<Opportunity> OppList = new List<Opportunity>();
for (Task t: Trigger.new){
OptyIDs.add(t.WhatID);
}
Map<ID, Opportunity> OptyMap = new Map<ID, Opportunity> ([Select ID,Last_Activity__c from Opportunity where ID in :OptyIDs]);
for (Task t: Trigger.new){
if (t.WhatID != NULL){
Opportunity OptyRec = OptyMap.get(t.WhatID);
If (((!t.subject.contains('Act-On Email')) )){
Optyrec.Last_Activity__c = t.ActivityDate;
}
if(!Ready4Update.contains(OptyRec.id)){
OppList.add(OptyRec);
Ready4Update.add(OptyRec.id);
}
}
}
if(OppList.size() > 0){
update oppList;
}
}
- Samwisematrix
- November 15, 2013
- Like
- 0
- Continue reading or reply
Javascript Onclick button - 'Null is not defined'
I have 4 text fields that I need to set to null. But am getting an error 'Null is not definied' when trying to use the button. Any feedback as to syntax for this?
Here is the relevant piece of my javascript Onclick button code:
var caseUpdate = new sforce.SObject("Case");
caseUpdate.Id = caseObj.Id;
caseUpdate.InEditUserId__c = Null;
caseUpdate.InEditUser__c =Null;
caseUpdate.InEditTime__c =Null;
caseUpdate.InEditViewURL__c=Null;
updateRecords.push(caseUpdate);
- Amphitrite
- November 13, 2013
- Like
- 0
- Continue reading or reply
Help bulkifying trigger
I'm wondering if someone could help me bulkify this trigger. As background, we have a custom object RBA_Invoice_Line_Item__c in master-detail to RBA_Participant__c and RBA_Invoice__c. We would like to get a double amount updated on the Participant based on the Invoice Date. If it's in the current month, the total amount from the Line Items would update "Current Month Total" on the Participant. The same would happen for Line Items where the invoice date = last month, to update a "Previous Month Total" field on Participant.
Here is the trigger:
trigger RBA_Invoice_Line_Item_RollupTrigger on RBA_Invoice_Line_Item__c (after update, after insert, after delete) { Map<Id, Double> previousMonthTotals = new Map<Id, Double>(); Map<Id, Double> currentMonthTotals = new Map<Id, Double>(); List<RBA_Participant__c> participantsToUpdate = new List<RBA_Participant__c>(); List<RBA_Invoice_Line_Item__c> itemsForParticipant; List<RBA_Invoice_Line_Item__c> items; if (trigger.isDelete) { items = trigger.old; } else { items = trigger.new; } // Go through all of the line items that the trigger // is acting on for (RBA_Invoice_Line_Item__c triggerItem: items) { // Get the participant's ID for the line item and then // ensure their ID exists in the previous / current month totals // maps and their totals default to $0.00 Id participant = triggerItem.RBA_Participant__c; if (!previousMonthTotals.containsKey(participant)) { previousMonthTotals.put(participant, 0.0); } if (!currentMonthTotals.containsKey(participant)) { currentMonthTotals.put(participant, 0.0); } // Sum the total cost of all previous month's line items // for the current participant (see participant above) // // 1. get all of the line items for the previous month // 2. for each line item update the mapping for the participant // to be (previous total + total cost) itemsForParticipant = [SELECT Id, Total_Cost__c FROM RBA_Invoice_Line_Item__c WHERE Invoice_Date__c = LAST_MONTH AND RBA_Participant__c = :participant]; for (RBA_Invoice_Line_Item__c item : itemsForParticipant) { // previous month total = current total cost + total cost of line item previousMonthTotals.put(participant, previousMonthTotals.get(participant) + item.Total_Cost__c); } // Sum the total cost of all current month's line items // for the current participant (see participant above) // // 1. get all of the line items for the current month // 2. for each line item update the mapping for the participant // to be (previous total + total cost) itemsForParticipant = [SELECT Id, Total_Cost__c FROM RBA_Invoice_Line_Item__c WHERE Invoice_Date__c = THIS_MONTH AND RBA_Participant__c = :participant]; for (RBA_Invoice_Line_Item__c item : itemsForParticipant) { // current month total = current total cost + total cost of line item currentMonthTotals.put(participant, currentMonthTotals.get(participant) + item.Total_Cost__c); } } // Collect all of the unique participant IDs from both // mappings into a list List<Id> participants = new List<Id>(); // First add all previous month unique participants for (Id previous : previousMonthTotals.keyset()) { participants.add(previous); } // ... then add any participants in the current month totals // that aren't in the previous month totals for (Id current : currentMonthTotals.keyset()) { if (!previousMonthTotals.containsKey(current)) { participants .add(current); } } // For each collected participant ID from the previous step, retrieve the participant // record from Salesforce then update their totals if and only if we collected // totals from them for (Id id : participants) { RBA_Participant__c participant = [SELECT Id, Previous_Month_Total__c, Current_Month_Total__c FROM RBA_Participant__c WHERE Id = :id]; if (previousMonthTotals.containsKey(id)) { participant.Previous_Month_Total__c = previousMonthTotals.get(id); } if (currentMonthTotals.containsKey(id)) { participant.Current_Month_Total__c = currentMonthTotals.get(id); } // Collect participant record in a list we will then batch update // once we are done looping participantsToUpdate.add(participant); } // Batch update all updated participants update participantsToUpdate; }
I see this in the debug log:
09:22:32.982|CUMULATIVE_PROFILING|SOQL operations| Trigger.RBA_Invoice_Line_Item_RollupTrigger: line 43, column 1: [SELECT Id, Total_Cost__c FROM RBA_Invoice_Line_Item__c WHERE Invoice_Date__c = LAST_MONTH AND RBA_Participant__c = :participant]: executed 51 times in 279 ms Trigger.RBA_Invoice_Line_Item_RollupTrigger: line 60, column 1: [SELECT Id, Total_Cost__c FROM RBA_Invoice_Line_Item__c WHERE Invoice_Date__c = THIS_MONTH AND RBA_Participant__c = :participant]: executed 50 times in 182 ms
but I'm not sure how/where to move those queries?
- Stephanie_Arce
- November 13, 2013
- Like
- 0
- Continue reading or reply
Sowing more than one row in apex:pageBlock
My Custom Visualforce page.
<apex:page controller="UnapprovedList">
<apex:pageBlock title="Opportunities">
<apex:pageBlockTable value="{!Opportunity}" var="item">
<apex:column value="{!item.Name}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
My Controller
public class UnapprovedList{
private final Opportunity opportunity;
public UnapprovedList() {
opportunity = [SELECT Id, Name FROM Opportunity limit 1];
// the page displays error if i remove limit 1.
//System.QueryException: List has more than 1 row for assignment to SObject
}
public Opportunity getOpportunity () {
return opportunity;
}
}
where is the problem?? i want to show more than one row but when i return multiple row the error pops up..
Any help would be appricated.
- Shanke_Paudel
- November 12, 2013
- Like
- 0
- Continue reading or reply
Need help in string formatting function.
I have a string which contains object names enclosed in <>. Like this:
String str = 'I have <name> and <id> and <phone>'; //The string may vary,so it needs to be dynamic
I need an output like this. So that i can use the field names to use it in my soql query.
String fields = 'name,id,phone';
- Dipa87
- November 05, 2013
- Like
- 0
- Continue reading or reply
Null Point Exception
Can some please review this and iam getting an null point exception at the line which is marked in red.
public List<Voucher__c> getRelatedVoucher() {
NumberEventsBenefiting = 0;
TotalRaffles = 0;
TotalEvents = 0;
RelatedVoucher = new List<Voucher__c>();
RelatedTreasureChestApplications = new List<Treasure_Chest_Application__c>();
this.Voucherid = 'a1Ac0000000VaCi';
if(Voucherid != null && Voucherid!= ''){
for(Voucher__c queryvouchers : [select (select Amount_Raised_for_Event__c,CreatedDate,Stage__c, Date_Accepted__c,
Amount_Raised_for_Voucher__c, Location_of_event__c,Name_of_the_Event__c,
Date_of_the_Event__c,Temporary_Voucher__r.Account__r.Name
from Treasure_Chest_Applications__r )
Total_Amount_Raised_for_Events__c,Total_Amount_Raised_for_Vouchers__c,Number_of_Events_Benefiting__c,Term__c,
Name,CreatedDate from Voucher__c where id=: Voucherid ]){
for(Treasure_Chest_Application__c TCA :queryvouchers.Treasure_Chest_Applications__r){
if((date.today().month() - TCA.Date_of_the_Event__c.month() == 1) && (date.today().year() == TCA.Date_of_the_Event__c.year())){
RelatedVoucher.add(queryvouchers);
}
}
}
for(Voucher__c CalVouchers : RelatedVoucher ){
NumberEventsBenefiting += Integer.valueOf(CalVouchers.Number_of_Events_Benefiting__c);
TotalRaffles += Integer.valueOf(CalVouchers.Total_Amount_Raised_for_Vouchers__c);
TotalEvents += Integer.valueOf(CalVouchers.Total_Amount_Raised_for_Events__c);
}
}
return RelatedVoucher;
}
- kandy11
- November 05, 2013
- Like
- 0
- Continue reading or reply
Auto Number
Hi All,
I need to populate Account name as ACC + year created + 9 digits( autonumber)
Example: Acc- 2013 - 100000001.......
Can anyone help me out ???? Thanks in Advance....
- Chenna4a2
- November 04, 2013
- Like
- 0
- Continue reading or reply
Code Coverage problem
- SureshKolli
- October 23, 2013
- Like
- 0
- Continue reading or reply
Visual Force page Code
Can anyone suggest the best way to achive this.
1. A Number value say 2500.00. has to be displayed in visual force page.
Things to consider is
1. Whole no should be displayed
2. if no value then display "n/a".
Final Expected value if not null is : $ 2500
Final value if null is : n/a
We can get number format by this
<apex:outputText value="{0,number,#,###,###}">
<apex:param value="{!Lead.number__c}"/>
</apex:outputText>
They way I have implemented is
<apex:outputPanel id="years_of_exp" rendered="{!IF(Lead.number__c==null || Lead.number__c==0, true,false)}"> N/A </apex:outputPanel> <apex:outputText rendered="{!IF(Lead.number__c!=null, true,false)}"> $ </apex:outputText> <apex:outputText value="{0,number,#,###,###}"> <apex:param value="{!Lead.Number__C}"/> </apex:outputText>
2. i have multi picklist values to be displayed.
Eg: value in db is light;bulb;tube;led;
but i want to display as
light, bulb, tube, led.
Right now i am using javascript at the front end and displaying the expected output.
i wam wondering there should be a better way.
Above two solution are expected in front end..
Thanks ,
Snippets
- snippets@sf
- October 23, 2013
- Like
- 0
- Continue reading or reply
Basic visualforce question
Hi there,
I am trying my hands on Visualforce and it's a very basic question. While on the Account controller, if I am pulling the account details such as CreatedBY it gives me the record ID and not the name. Similary, I am not able to print the TickerSymbol.
Here is the code - please help out.
<apex:page standardController="Account">
Hello {!$User.FirstName}. <BR/>
The current Account {!Account.Name} record has been created by: {!Account.CreatedBy}. The industry of the account is: {!Account.Industry}<BR/> The ticker symbol for the account is {!Account.TickerSymbol}
</apex:page>
PS: Should I be writing a Controller extension with the SOQL in it.
Select Username, Manager.Name from User
- sbeniwal
- October 21, 2013
- Like
- 0
- Continue reading or reply
- imAkashGarg
- October 18, 2013
- Like
- 0
- Continue reading or reply
junction object between contact and product
i am not able to make a junction object between contact and product. because there is no option to create MD on product object.
please suggest an alternative approach, if this is not possible.
thanks.
- imAkashGarg
- October 18, 2013
- Like
- 0
- Continue reading or reply
Emulate 'Edit' button for Opportunity page
I want to add a validation before one user edit an opportunity.
I have created a new custom button and I want to show an alert and after it open the opportunity in edit mode.
I have googled a lot of time and I don't find anything.
Any help in how to achive that?
Thanks,
- David.HE
- October 15, 2013
- Like
- 0
- Continue reading or reply
Error: Component <apex:inputFile> definition does not contain <apex:componentBody>
Hi guys, I am trying to take .csv file as input inserting into Documents but I am receiveing an error
Error: Component <apex:inputFile> definition does not contain <apex:componentBody> so it cannot be used with any child tags.
My code are
<apex:page controller="ExcelController"> <apex:form> <apex:inputfile value="{!document.body}"> <apex:commandbutton action="{!readExcelData}" value="Upload"></apex:commandbutton> </apex:inputfile> </apex:form> </apex:page>
and controller is
public with sharing class ExcelDempController { public Document document { get; set; } public String excelData { get; set; } public ExcelDempController() { document = new Document(); excelData = ''; } public void readExcelData() { } }
as you can see i haven't written any complex code then why this is giving me error
I am not able to figure it out what's the mistake i am doing??
Thanks
- Puneet _Mishra
- October 15, 2013
- Like
- 0
- Continue reading or reply
Extract Owner ID details from Account
I want to extract ownerId and the user related details from Account , so writing the query :
SELECT Id,OwnerId,OwnerId__r.DefaultDivision FROM Account where Id in (....
Its giving error :
Didn't understand relationship 'OwnerId__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
Please suggest.
- RajeevlsHyd
- October 15, 2013
- Like
- 0
- Continue reading or reply
Dealing with two vf pages having one controller
Hi all,
I have Request__c object , I overridden new , edit , view by createRequest , EditRequest , ViewRequest pages respectively and in createRequest page I have button to create request and controller have createRequest() method in this method I created new request__c object with required Fields like request_type__c .
EditRequest ,ViewRequest both are sharing same controller ManageRequestController
Now I need to redirect page to EditRequest from createRequest() so I written following code
PageReference pRef = new PageReference ('/' + request.id );
pRef.setRedirect(true);
return pRef ;
So this code is opening ViewRequest instead of EditRequest . I need to redirect to EditRequest so please help me in doing this..
- Venky1219
- October 11, 2013
- Like
- 0
- Continue reading or reply
System.NullPointerException: Attempt to de-reference a null object
trigger updateCount on Student__c (after insert, after delete) { Integer clist=0; if(Trigger.isAfter && Trigger.isInsert) { for (Student__c stent : Trigger.new) { Id cid = stent.Class__c; clist = [Select Count() FROM Student__c where Class__c =: cid ]; if(stent.Class__r.My_Count__c == null) { stent.addError('null'); } else { stent.Class__r.My_Count__c = clist + 1; } } } else if(Trigger.isAfter && Trigger.isDelete) { for (Student__c stent : Trigger.old) { Id cid = stent.Class__c; clist = [Select Count() FROM Student__c where Class__c =: cid ]; stent.Class__r.My_Count__c = clist - 1; } } }
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger updateCount caused an unexpected exception, contact your administrator: updateCount: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.updateCount: line 19, column 1
- @GM
- October 10, 2013
- Like
- 0
- Continue reading or reply
Getting child object values using parent Id
Hi all,
I have Responses__c and Response_Type__c objects . Response_Type__c is parent to Responses__c . Now I have Response_Type__c Id so written Query as follows to get Response_type__c fields as well as Responses__c fields
List<Response_type__c> rtList = [select id,name,(select id,name from responses__c) from Response_type__c where id =: rt.id];
Now it raising error
Error: TestController Compile Error: Didn't understand relationship 'responses__c' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
then I changed the query as follows
List<Response_type__c> rtList = [select id,name,(select id,name from responses__r) from Response_type__c where id =: rt.id];
still the same error
Error: TestController Compile Error: Didn't understand relationship 'responses__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
so please help me in resolving this. please explain what is root cause
- Venky1219
- October 10, 2013
- Like
- 0
- Continue reading or reply
trigger that compare old value with new value
HI Everyone
plz check my requirement
In contact two fields are there one is mobile and another is phone
i need to avoid duplicate values in the both fields
ex :let us take in first record i enter moblie=909090 and phone=808080
when i am entering second record mobile=808080 and phone=909090(here i want through an error that moile number or phone is already exhists with another record)
thanks in advance
- sunnysfdcdvp
- October 09, 2013
- Like
- 0
- Continue reading or reply
System.ListException: List index out of bounds: 0:
Apex trigger StudentInsertMaxLimit caused an unexpected exception, contact your administrator: StudentInsertMaxLimit: execution of BeforeInsert caused by: System.ListException: List index out of bounds: 0: Trigger.StudentInsertMaxLimit: line 12, column 1
code:
trigger StudentInsertMaxLimit on Student__c (before insert) {
if(Trigger.isInsert)
{
for(Student__c stu:Trigger.new)
{
list<Student__c> stuList=[select Class__r.NumberOfStudents__c,Class__r.MaxSize__c from student__c where id=:stu.id];
if(Integer.Valueof(stuList.get(0)) == Integer.Valueof(stuList.get(1)))
{
stu.addError('Maximum limit of students in a class is reached');
}
}
}
}
- @GM
- October 08, 2013
- Like
- 0
- Continue reading or reply
An internal server error has occurred : Error ID: 1838907660-1664 (701532195)
I am getting below error while uploading unmanaged package:
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
An internal server error has occurred An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience.
Thank you again for your patience and assistance. And thanks for using salesforce.com!
Error ID: 1838907660-1664 (701532195)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Is there a way around?
Thank you for your help!!
Dhaval Panchal
Gyansys Infotech pvt ltd.
Bangalore
- Dhaval Panchal
- November 14, 2014
- Like
- 0
- Continue reading or reply
Add custom button related list of user detail page
I want to create custom page for two functionalities of User.
1. Default Opportunity Team
2. Default Account Team
Both are related list on User detail page.
But I am not able to add custom button on both of the related list.
Any one have idea how to do this?
Thanks,
Dhaval
- Dhaval Panchal
- April 29, 2014
- Like
- 0
- Continue reading or reply
Not able to login in salesforce using SOAP API
I am using SOAP API in C#.net. Every time I tried to login in sandbox it gives an error that "The remote name could not be resolved: 'test.salesforce.com'. Very frequently I am getting this error. I checked my credentials and token all are fine. If I tried to login 5-6 time, some time it works and most of the time it gives me this error.
Please help me if you have any ideas.
Thanks,
Dhaval
- Dhaval Panchal
- February 05, 2014
- Like
- 0
- Continue reading or reply
Strange Issue with Bulk Upsert: INVALID_CROSS_REFERENCE_KEY
I am facing strange issue with Bulk API (insert/upsert).
below is the error:
Error in upsert (Account) record:
Error Message - Record Type ID: this ID value isn't valid for the user:
Status Code - INVALID_CROSS_REFERENCE_KEY
Fields: RecordTypeId
But when I use SOAP API it works perfact this issue only occurs when I use Bulk API.
Any Idea?
Thanks,
Dhaval Panchal
- Dhaval Panchal
- January 23, 2014
- Like
- 1
- Continue reading or reply
Urgent : Error in Bulk API (InvalidBatch : Failed to parse XML. Found invalid XML. entity reference names can not start with character ' ' )
I am using Bulk Api with C#.net.
every time I am getting below error if xml file has more than 50 records.
<stateMessage>InvalidBatch : Failed to parse XML. Found invalid XML. entity reference names can not start with character ' ' (position: START_TAG seen ...<SMS_Zip_Code_Map_EUC__c>J & ... @1:72405)</stateMessage>
Below 50 records It works fine.
Anyone has some idea?
Thanks in Advance,
Dhaval Panchal
- Dhaval Panchal
- January 23, 2014
- Like
- 0
- Continue reading or reply
Urgent :: Error in Bulk API (InvalidBatch : Failed to parse XML. Found invalid XML. entity reference names can not start with character ' ' )
I am using Bulk Api with C#.net.
every time I am getting below error if xml file has more than 50 records.
<stateMessage>InvalidBatch : Failed to parse XML. Found invalid XML. entity reference names can not start with character ' ' (position: START_TAG seen ...<SMS_Zip_Code_Map_EUC__c>J & ... @1:72405)</stateMessage>
Below 50 records It works fine.
Anyone has some idea?
Thanks in Advance,
Dhaval Panchal
- Dhaval Panchal
- January 23, 2014
- Like
- 0
- Continue reading or reply
Issue in creating job (C#)
I am trying to create job in C#. But I am getting issue with version.
Code:
I am getting below response:
Error code: BadRequest
<?xml version="1.0" encoding="UTF-8"?>
<error xmlns="http://www.force.com/2009/06/asyncapi/dataload">
<exceptionCode>InvalidUrl</exceptionCode>
<exceptionMessage>unknown version: 10.0</exceptionMessage>
</error>
I am trying to use bulk api with C#.net, But I donot have any idea about this. Please help me.
Thanks,
Dhaval
- Dhaval Panchal
- January 14, 2014
- Like
- 1
- Continue reading or reply
BULK API With C#.NET Urgent...
Anyone have sample code for salesforce - C#.net integration using BULK Api?
- Dhaval Panchal
- January 14, 2014
- Like
- 1
- Continue reading or reply
Urgent::Salesforce Integration with .net
Hi,
How many different ways to integrate .net with salesforce?
I tried using enterprice.wsdl. I was able to connect with salesforce but there are some problems using enterprise.wsdl
1. we need to get enterprise.wsdl if we need to use this code with other environment (i.e. if we have used sandbox during development and then we need to use that code with production)
2. every time we need to get latest enterprice.wsdl if we make changes to salesforce metadata.
I want to make it dynamic like java. I have integrated salesforce with java and it was dynamic (using parner.wsdl). But I donot have idea for .net.
Any one provide me sample code?
- Dhaval Panchal
- November 19, 2013
- Like
- 0
- Continue reading or reply
how to open ".xsx" (schema file) file?
Hi.
Anyone have a idea how to open ".xsx" (its a schema file) file? Which tool i can use?
- Dhaval Panchal
- November 18, 2013
- Like
- 0
- Continue reading or reply
Create Static Resource Dynamically
Hi,
I want to create Static Resource using apex code, but it gives me below error.
Error: Compile Error: DML not allowed on StaticResource
from below link I found that we can create static resource using metadata api.
But how to use metadata api in salesforce?
Any one have sample code for that?
- Dhaval Panchal
- November 05, 2013
- Like
- 0
- Continue reading or reply
Action function is not working.
Hi,
Below is my vf page. I have used action function control and java script to call controller method. When I have created this page, it was working perfactly. But today it is not working, I am not able to find any reason for that. If I use action in commandbutton directly then it works fine (that means my controller works fine). But as per my requirement I have to call that action using action function as this is a popup page.
<apex:page id="pg" controller="GeneralSettingsController" sidebar="false" showHeader="false"> <apex:pageMessages id="msg"/> <apex:form id="frm"> <apex:PageBlock id="pb"> <apex:pageBlockButtons > <apex:commandButton value="Save Settings" onclick="SaveSettings();"/> <apex:commandButton value="Cancel" onclick="window.close();"/> </apex:pageBlockButtons> Save Status: <B>{!saveStatus}</B><BR/><BR/> Remove chat history prior to <apex:inputField style="width:30px" value="{!objSetting.Time_Digit__c}"/> <apex:selectList style="width:75px" size="1" multiselect="false" value="{!objSetting.Time_Unit__c}"> <apex:selectOption itemValue="Minutes" itemLabel="Minutes"/> <apex:selectOption itemValue="Hours" itemLabel="Hours"/> <apex:selectOption itemValue="Days" itemLabel="Days"/> </apex:selectList> </apex:PageBlock> <apex:actionFunction oncomplete="window.close();" id="afSaveSettingValues" name="SaveSettingValues" action="{!SaveSettings}"/> </apex:form> <script> function SaveSettings(){ pg:frm:SaveSettingValues(); } </script> </apex:page>
Please give me some suggestion to find out cause.
- Dhaval Panchal
- October 28, 2013
- Like
- 0
- Continue reading or reply
Urgent :: DODGE Leads...
Hi,
Any one have some idea about DODGE Leads? I do not have any idea about DODGE Leads and I needs to import DODGE Leads to the salesforce. Please help me.
- Dhaval Panchal
- October 23, 2013
- Like
- 0
- Continue reading or reply
Urgent :: DODGE Leads..
Hi,
Any one have some idea about DODGE Leads? I do not have any idea about DODGE Leads and I needs to import DODGE Leads to the salesforce. Please help me.
- Dhaval Panchal
- October 23, 2013
- Like
- 0
- Continue reading or reply
Urgent :: DODGE Leads
Hi,
Any one have some idea about DODGE Leads? I do not have any idea about DODGE Leads and I needs to import DODGE Leads to the salesforce. Please help me.
- Dhaval Panchal
- October 23, 2013
- Like
- 0
- Continue reading or reply
Need help to create Exandable/collapsable list
Hi,
I want to display list like below.
------------------------------------------------------------------
- | Parent 1
------------------------------------------------------------------
| X | child 1
------------------------------------------------------------------
| X | child 2
------------------------------------------------------------------
| X | child 3
------------------------------------------------------------------
+ | Parent 2
------------------------------------------------------------------
+ | Parent 3
------------------------------------------------------------------
There is "+" before parent records, if we click on "+", it should be expand its childs.
If it is possible that child records can be display using pageblock table then it is very good.
Anyone have idea how to develop this in vf page?
- Dhaval Panchal
- September 30, 2013
- Like
- 0
- Continue reading or reply
What is Action?
Hi,
Anybody knows what is an action? (i.e. Setup -> Customization -> Case -> Buttons, Links and Action -> New Action)
How to use this action.
- Dhaval Panchal
- September 24, 2013
- Like
- 0
- Continue reading or reply
Converting s-control to VF Page
Hi,
I need to convert some s-controls to vf page. But I do not have any idea about s-control. There are some s-controls are created. I want to know how to run s-control. (i.e. we can run vf page using url https://..../apex/testvf, how to run s-control).
And what are the steps we need to keep in mind while converting s-controls to vf page. Is there any easiest way to do this?
- Dhaval Panchal
- September 24, 2013
- Like
- 0
- Continue reading or reply
"npm install forceios" not working in windows 7
Hi,
I am trying to install iOS SDK on windows 7 plateform. I have installed node on my system (as per instruction on http://www2.developerforce.com/en/mobile/getting-started/ios). No I am trying to run below command on command promt.
>npm install forceios
I am getting below result.
npm http GET https://registry.npmjs.org/forceios npm http 304 https://registry.npmjs.org/forceios npm ERR! notsup Unsupported npm ERR! notsup Not compatible with your operating system or architecture: force ios@2.0.3 npm ERR! notsup Valid OS: darwin npm ERR! notsup Valid Arch: any npm ERR! notsup Actual OS: win32 npm ERR! notsup Actual Arch: ia32 npm ERR! System Windows_NT 6.1.7601 npm ERR! command "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program File s (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "forceios" npm ERR! cwd E:\Salesforce\iOS Integratation\SalesforceMobileSDK-iOS-master npm ERR! node -v v0.10.18 npm ERR! npm -v 1.3.8 npm ERR! code EBADPLATFORM npm ERR! npm ERR! Additional logging details can be found in: npm ERR! E:\Salesforce\iOS Integratation\SalesforceMobileSDK-iOS-master\npm- debug.log
Not able to find any solution for this error. Also tried to remove os dependency (as per https://github.com/dmcquay/node-apac/pull/32 ) but i didn't find os list in package.json file.
Anybody have idea how to install forceios on windows 7 plateform?
- Dhaval Panchal
- September 20, 2013
- Like
- 0
- Continue reading or reply
Urgent, Need to develop Salesforce Webservice.
Hello,
I want to create on webservice, which can be accessed from outside of salesforce to fatch salesforce data. I want this only for lead and opportunity object.
I have created below sample webservice
global class wsReadLeads{ webService static String readLead(String LeadId){ List<Lead> lstLead = [Select Id, Email, Status, Name, Phone From Lead Where Id=:leadId]; String strLead = ''; if(lstLead.size()>0){ strLead = 'Lead : ' + lstLead[0].Name; strLead += 'Status : ' + lstLead[0].Status; strLead += 'Email : ' + lstLead[0].Email; strLead += 'Phone : ' + lstLead[0].Phone; strLead += 'Id : ' + lstLead[0].Id; } else{ strLead = '<B>No lead found</B>'; } return strLead; } }
now i want to access it from out side (SAP). how should i do this?
I tried this using html form tag (using post method). it shows below error.
<soapenv:Envelope> <soapenv:Body> <soapenv:Fault> <faultcode>soapenv:Client</faultcode> <faultstring>content-type of the request should be text/xml</faultstring> </soapenv:Fault> </soapenv:Body> </soapenv:Envelope>
below is my code to access web service
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Untitled Document</title> </head> <form name="myform" action="https://ap1.salesforce.com/services/Soap/class/wsReadLeads?un=test@xyz.com&pw=XXXXXX" method="POST"> <!--<input type="hidden" name="LeadId" value="<soap><body><LeadId>00Q90000003d8lN</LeadId></soap></body>" />--> <textarea rows="20" cols="100" name="LeadId"> <?xml version="1.0"?> <soapenv:Envelope> <soapenv:Body> <parameters> <LeadId>00Q90000003d8lN</LeadId> </parameters> </soapenv:Body> </soapenv:Envelope> </textarea> <!--<label for="first_name">Lead Id</label> <input id="LeadId" maxlength="40" name="LeadId" size="20" type="text" /><br>--> <input type="submit" value="Submit"> </form> </html>
any one can help me on this?
- Dhaval Panchal
- September 09, 2013
- Like
- 0
- Continue reading or reply
Strange Issue with Bulk Upsert: INVALID_CROSS_REFERENCE_KEY
I am facing strange issue with Bulk API (insert/upsert).
below is the error:
Error in upsert (Account) record:
Error Message - Record Type ID: this ID value isn't valid for the user:
Status Code - INVALID_CROSS_REFERENCE_KEY
Fields: RecordTypeId
But when I use SOAP API it works perfact this issue only occurs when I use Bulk API.
Any Idea?
Thanks,
Dhaval Panchal
- Dhaval Panchal
- January 23, 2014
- Like
- 1
- Continue reading or reply
Issue in creating job (C#)
I am trying to create job in C#. But I am getting issue with version.
Code:
I am getting below response:
Error code: BadRequest
<?xml version="1.0" encoding="UTF-8"?>
<error xmlns="http://www.force.com/2009/06/asyncapi/dataload">
<exceptionCode>InvalidUrl</exceptionCode>
<exceptionMessage>unknown version: 10.0</exceptionMessage>
</error>
I am trying to use bulk api with C#.net, But I donot have any idea about this. Please help me.
Thanks,
Dhaval
- Dhaval Panchal
- January 14, 2014
- Like
- 1
- Continue reading or reply
BULK API With C#.NET Urgent...
Anyone have sample code for salesforce - C#.net integration using BULK Api?
- Dhaval Panchal
- January 14, 2014
- Like
- 1
- Continue reading or reply
Formating date time
Hi,
I want to convert datetime value
i.e. currently I am getting value "Mon Aug 26 11:49:39 GMT 2013" and I want to convert it to "26-Aug-13 11:49 PM"
Any Ideas?
I want to apply formatting on standard "CreatedDateTime" field.
- Dhaval Panchal
- August 26, 2013
- Like
- 1
- Continue reading or reply
How to remove custom fields using Metadata API (Bulk delete custom fields)
Hello,
I want to delete 500+ custom fields. Is there any solution to mass remove custom fields? I have tried with metadata Api using below code. But it gives me below error.
Object with id:04s900000037qo4AAA is InProgress
Error status code: INVALID_CROSS_REFERENCE_KEY
Error message: In field: members - no CustomField named Custom_Field__c found
Object with id:04s900000037qo4AAA is Error
Below is the code:
public void deleteCustomField(String fullname) throws Exception
{
CustomField customField = new CustomField();
customField.setFullName(fullname);
UpdateMetadata updateMetadata = new UpdateMetadata();
updateMetadata.setMetadata(customField);
updateMetadata.setCurrentName(fullname);
AsyncResult[] asyncResults = metadataConnection.delete(new Metadata[] {customField});
long waitTimeMilliSecs = ONE_SECOND;
do
{
printAsyncResultStatus(asyncResults);
waitTimeMilliSecs *= 2;
Thread.sleep(waitTimeMilliSecs);
asyncResults = metadataConnection.checkStatus(new String[]{asyncResults[0].getId()});
} while (!asyncResults[0].isDone());
printAsyncResultStatus(asyncResults);
}
private void printAsyncResultStatus(AsyncResult[] asyncResults) throws Exception {
if (asyncResults == null || asyncResults.length == 0 || asyncResults[0] == null) {
throw new Exception("The object status cannot be retrieved");
}
AsyncResult asyncResult = asyncResults[0]; //we are creating only 1 metadata object
if (asyncResult.getStatusCode() != null) {
System.out.println("Error status code: " +
asyncResult.getStatusCode());
System.out.println("Error message: " + asyncResult.getMessage());
}
System.out.println("Object with id:" + asyncResult.getId() + " is " +
asyncResult.getState());
}
Is there any other solution (any app) to removing custom fields?
Thanks in advance,
Dhaval Panchal
- Dhaval Panchal
- August 19, 2013
- Like
- 1
- Continue reading or reply
How to remove custom fields using Metadata API (Bulk delete custom fields)
Hello,
I want to delete 500+ custom fields. Is there any solution to mass remove custom fields? I have tried with metadata Api using below code. But it gives me below error.
Object with id:04s900000037qo4AAA is InProgress
Error status code: INVALID_CROSS_REFERENCE_KEY
Error message: In field: members - no CustomField named Custom_Field__c found
Object with id:04s900000037qo4AAA is Error
Below is the code:
public void deleteCustomField(String fullname) throws Exception
{
CustomField customField = new CustomField();
customField.setFullName(fullname);
UpdateMetadata updateMetadata = new UpdateMetadata();
updateMetadata.setMetadata(customField);
updateMetadata.setCurrentName(fullname);
AsyncResult[] asyncResults = metadataConnection.delete(new Metadata[] {customField});
long waitTimeMilliSecs = ONE_SECOND;
do
{
printAsyncResultStatus(asyncResults);
waitTimeMilliSecs *= 2;
Thread.sleep(waitTimeMilliSecs);
asyncResults = metadataConnection.checkStatus(new String[]{asyncResults[0].getId()});
} while (!asyncResults[0].isDone());
printAsyncResultStatus(asyncResults);
}
private void printAsyncResultStatus(AsyncResult[] asyncResults) throws Exception {
if (asyncResults == null || asyncResults.length == 0 || asyncResults[0] == null) {
throw new Exception("The object status cannot be retrieved");
}
AsyncResult asyncResult = asyncResults[0]; //we are creating only 1 metadata object
if (asyncResult.getStatusCode() != null) {
System.out.println("Error status code: " +
asyncResult.getStatusCode());
System.out.println("Error message: " + asyncResult.getMessage());
}
System.out.println("Object with id:" + asyncResult.getId() + " is " +
asyncResult.getState());
}
Is there any other solution (any app) to removing custom fields?
Thanks in advance,
Dhaval Panchal
- Dhaval Panchal
- August 19, 2013
- Like
- 1
- Continue reading or reply
An internal server error has occurred : Error ID: 1838907660-1664 (701532195)
I am getting below error while uploading unmanaged package:
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
An internal server error has occurred An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience.
Thank you again for your patience and assistance. And thanks for using salesforce.com!
Error ID: 1838907660-1664 (701532195)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Is there a way around?
Thank you for your help!!
Dhaval Panchal
Gyansys Infotech pvt ltd.
Bangalore
- Dhaval Panchal
- November 14, 2014
- Like
- 0
- Continue reading or reply
Strange Issue with Bulk Upsert: INVALID_CROSS_REFERENCE_KEY
I am facing strange issue with Bulk API (insert/upsert).
below is the error:
Error in upsert (Account) record:
Error Message - Record Type ID: this ID value isn't valid for the user:
Status Code - INVALID_CROSS_REFERENCE_KEY
Fields: RecordTypeId
But when I use SOAP API it works perfact this issue only occurs when I use Bulk API.
Any Idea?
Thanks,
Dhaval Panchal
- Dhaval Panchal
- January 23, 2014
- Like
- 1
- Continue reading or reply
Urgent :: Error in Bulk API (InvalidBatch : Failed to parse XML. Found invalid XML. entity reference names can not start with character ' ' )
I am using Bulk Api with C#.net.
every time I am getting below error if xml file has more than 50 records.
<stateMessage>InvalidBatch : Failed to parse XML. Found invalid XML. entity reference names can not start with character ' ' (position: START_TAG seen ...<SMS_Zip_Code_Map_EUC__c>J & ... @1:72405)</stateMessage>
Below 50 records It works fine.
Anyone has some idea?
Thanks in Advance,
Dhaval Panchal
- Dhaval Panchal
- January 23, 2014
- Like
- 0
- Continue reading or reply
McGraw-Hill Construction Dodge Data Integration to salesforce
Hi,
Using Dodge tool all the leads from "McGraw-Hill Construction" are updating to salesforce. This is there by installing package to salesforce. But now my client requirement is, I have to integrate to McGraw-Hill Construction Dodge tool for updating all records to salesforce using salesforce APex integration process. i'e using API s of Dodge tool. Is there any way to implement using rest Api or SOAP inorder to connect directly by salesforce coding.
- Ram@sfdc
- November 27, 2013
- Like
- 0
- Continue reading or reply
Urgent::Salesforce Integration with .net
Hi,
How many different ways to integrate .net with salesforce?
I tried using enterprice.wsdl. I was able to connect with salesforce but there are some problems using enterprise.wsdl
1. we need to get enterprise.wsdl if we need to use this code with other environment (i.e. if we have used sandbox during development and then we need to use that code with production)
2. every time we need to get latest enterprice.wsdl if we make changes to salesforce metadata.
I want to make it dynamic like java. I have integrated salesforce with java and it was dynamic (using parner.wsdl). But I donot have idea for .net.
Any one provide me sample code?
- Dhaval Panchal
- November 19, 2013
- Like
- 0
- Continue reading or reply
attempt to dereference a null object
Below is my Code. I am getting an error that I am attepting to dereference a null object. I am not sure how to fix it. I am very new to writtng triggers and any help would be very appriciated.
trigger LastActDate3 on Task (after insert, after update) {
Set <ID> OptyIDs = new Set <ID> ();
Set<Id> Ready4Update = new Set<Id>();
List<Opportunity> OppList = new List<Opportunity>();
for (Task t: Trigger.new){
OptyIDs.add(t.WhatID);
}
Map<ID, Opportunity> OptyMap = new Map<ID, Opportunity> ([Select ID,Last_Activity__c from Opportunity where ID in :OptyIDs]);
for (Task t: Trigger.new){
if (t.WhatID != NULL){
Opportunity OptyRec = OptyMap.get(t.WhatID);
If (((!t.subject.contains('Act-On Email')) )){
Optyrec.Last_Activity__c = t.ActivityDate;
}
if(!Ready4Update.contains(OptyRec.id)){
OppList.add(OptyRec);
Ready4Update.add(OptyRec.id);
}
}
}
if(OppList.size() > 0){
update oppList;
}
}
- Samwisematrix
- November 15, 2013
- Like
- 0
- Continue reading or reply
Compile Error: alias is too long, maximum of 25 characters
I created a new custom field that is a replacement of an existing one. The existing field is referenced in an Apex Class. When I attempt to update the Apex Class with the new field API name I receive the following error:
Error: Compile Error: alias is too long, maximum of 25 characters
Has anyone seen this error before? Any suggestions on how to correct it?
Thanks
- Holtzy
- November 15, 2013
- Like
- 0
- Continue reading or reply
Issue with code deployment due to an error
Hi,
I'm receiving the following error for code that has existed in our org for several years - I've only changed the reference from Estimated_Volume__c to Estimated_Annual_Volume__c.
Method does not exist or incorrect signature: EncodingUtil.urlEncode(Decimal, String)
Original lines:
if(rec.Estimated_Volume__c != null){
url += '&' + '00N600000029OCc=' + EncodingUtil.urlEncode(rec.Estimated_Volume__c,'UTF-8');
Revised lines:
if(rec.Estimated_Annual_Volume__c != null){
url += '&' + '00N600000029OCc=' + EncodingUtil.urlEncode(rec.Estimated_Annual_Volume__c,'UTF-8');
Any help would be greatly appreciated!
Thanks!
- krawl78
- November 15, 2013
- Like
- 0
- Continue reading or reply
Why some times developer console will not open log
Hi ,
Can any once face this problem when we executin some code using developer console the log will not open.
Any one face this problem.
Thank you
- V'Nath
- November 15, 2013
- Like
- 0
- Continue reading or reply
Error:You have uncommitted work pending. Please commit or rollback before calling out
Hi,
I'm getting 'You have uncommitted work pending. Please commit or rollback before calling out' msg when I run my test class. Can somebody help me to fix this please?
global class LeadCallOutBatchable implements Database.Batchable<sObject>, Database.AllowsCallouts{
global final String Query;
global final String Entity;
global LeadCallOutBatchable() {
Query='SELECT Id, FirstName, LastName, UserName__c, Email, Title, fs_skills__c, fs_overview__c, fs_facebook__c, fs_twitter__c, fs_linkedin__c ' + 'FROM Lead WHERE UserName__c != null';
Entity= 'Lead';
}
global Database.QueryLocator start(Database.BatchableContext BC) {
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<Lead> scope) {
List<Lead> leadsToUpdate = new List<Lead>();
String PersonURL ;
Integer count = 0;
System.debug('scope: ' + scope);
for(Lead leadRec : scope ) {
String jResponse = '';
JPersonList deserialPersonList = new JPersonList();
count++;
System.debug('Count: ' + count);
PersonURL = URL
try {
HttpRequest req = new HttpRequest();
req.setMethod('GET');
String username = JUSERNAME;
String password = JPW;
Blob headerValue = Blob.valueOf(username + ':' + password);
String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
req.setHeader('Authorization', authorizationHeader);
req.setHeader('Accept', 'application/json');
req.setEndPoint(PersonURL);
Http http = new Http();
system.debug('req: ' + req);
HTTPResponse res = http.send(req);
jResponse = res.getBody();
jResponse = jResponse.Replace('throw \'allowIllegalResourceCall is false.\';', '');
//System.debug('Request Body: ' + jResponse);
JSONParser parser = JSON.createParser(jResponse);
// deserialize
JObject personRecord = (JObject) System.JSON.deserialize(jResponse, JObject.class);
//some codes to compare
leadsToUpdate.add(leadRec);
System.debug('leadsToUpdate: ' + leadsToUpdate);
}
}
catch(Exception ex) {
System.debug('Exception: ' + ex);
}
}
System.debug('leadsToUpdate: ' + leadsToUpdate);
update leadsToUpdate;
}
global void finish(Database.BatchableContext BC){
}
}
test classes:
@isTest
public class LeadCalloutBatchableTest{
public static testmethod void TestLeadCalloutBatchable() {
List<ID> acRecs=new List<ID>();
Lead testLead = new Lead( IncludeInSFToSync__c = true, FirstName = 'STEVE' , LastName = 'JOHN', UserName__c = 'stevej', Email = 'r@gmail.com', Title = 'testtest', fs_skills__c = 'developement' , fs_overview__c='good', fs_facebook__c='facebook', fs_twitter__c='twitter', fs_linkedin__c = 'linkedin');
insert testLead;
acRecs.add(testLead.id);
string JSONstr =
SingleRequestMock fakeResponse = new SingleRequestMock(200,'Complete', JSONstr ,null);
Test.startTest();
Test.setMock(HttpCalloutMock.class, fakeResponse);
Database.executeBatch(new LeadCallOutBatchable(), 200);
Test.stopTest();
}
}
@isTest
global class SingleRequestMock implements HttpCalloutMock {
protected Integer code;
protected String status;
protected String bodyAsString;
protected Blob bodyAsBlob;
protected Map<String, String> responseHeaders;
public SingleRequestMock(Integer code, String status, String body, Map<String, String> responseHeaders) {
this.code = code;
this.status = status;
this.bodyAsString = body;
this.bodyAsBlob = null;
this.responseHeaders = responseHeaders;
}
public SingleRequestMock(Integer code, String status, Blob body, Map<String, String> responseHeaders) {
this.code = code;
this.status = status;
this.bodyAsBlob = body;
this.bodyAsString = null;
this.responseHeaders = responseHeaders;
}
public HTTPResponse respond(HTTPRequest req) {
HttpResponse resp = new HttpResponse();
resp.setStatusCode(code);
resp.setStatus(status);
if (bodyAsBlob != null) {
resp.setBodyAsBlob(bodyAsBlob);
} else {
resp.setBody(bodyAsString);
}
if (responseHeaders != null) {
for (String key : responseHeaders.keySet()) {
resp.setHeader(key, responseHeaders.get(key));
}
}
return resp;
}
}
- Aaran
- November 13, 2013
- Like
- 0
- Continue reading or reply
Javascript Onclick button - 'Null is not defined'
I have 4 text fields that I need to set to null. But am getting an error 'Null is not definied' when trying to use the button. Any feedback as to syntax for this?
Here is the relevant piece of my javascript Onclick button code:
var caseUpdate = new sforce.SObject("Case");
caseUpdate.Id = caseObj.Id;
caseUpdate.InEditUserId__c = Null;
caseUpdate.InEditUser__c =Null;
caseUpdate.InEditTime__c =Null;
caseUpdate.InEditViewURL__c=Null;
updateRecords.push(caseUpdate);
- Amphitrite
- November 13, 2013
- Like
- 0
- Continue reading or reply
Help bulkifying trigger
I'm wondering if someone could help me bulkify this trigger. As background, we have a custom object RBA_Invoice_Line_Item__c in master-detail to RBA_Participant__c and RBA_Invoice__c. We would like to get a double amount updated on the Participant based on the Invoice Date. If it's in the current month, the total amount from the Line Items would update "Current Month Total" on the Participant. The same would happen for Line Items where the invoice date = last month, to update a "Previous Month Total" field on Participant.
Here is the trigger:
trigger RBA_Invoice_Line_Item_RollupTrigger on RBA_Invoice_Line_Item__c (after update, after insert, after delete) { Map<Id, Double> previousMonthTotals = new Map<Id, Double>(); Map<Id, Double> currentMonthTotals = new Map<Id, Double>(); List<RBA_Participant__c> participantsToUpdate = new List<RBA_Participant__c>(); List<RBA_Invoice_Line_Item__c> itemsForParticipant; List<RBA_Invoice_Line_Item__c> items; if (trigger.isDelete) { items = trigger.old; } else { items = trigger.new; } // Go through all of the line items that the trigger // is acting on for (RBA_Invoice_Line_Item__c triggerItem: items) { // Get the participant's ID for the line item and then // ensure their ID exists in the previous / current month totals // maps and their totals default to $0.00 Id participant = triggerItem.RBA_Participant__c; if (!previousMonthTotals.containsKey(participant)) { previousMonthTotals.put(participant, 0.0); } if (!currentMonthTotals.containsKey(participant)) { currentMonthTotals.put(participant, 0.0); } // Sum the total cost of all previous month's line items // for the current participant (see participant above) // // 1. get all of the line items for the previous month // 2. for each line item update the mapping for the participant // to be (previous total + total cost) itemsForParticipant = [SELECT Id, Total_Cost__c FROM RBA_Invoice_Line_Item__c WHERE Invoice_Date__c = LAST_MONTH AND RBA_Participant__c = :participant]; for (RBA_Invoice_Line_Item__c item : itemsForParticipant) { // previous month total = current total cost + total cost of line item previousMonthTotals.put(participant, previousMonthTotals.get(participant) + item.Total_Cost__c); } // Sum the total cost of all current month's line items // for the current participant (see participant above) // // 1. get all of the line items for the current month // 2. for each line item update the mapping for the participant // to be (previous total + total cost) itemsForParticipant = [SELECT Id, Total_Cost__c FROM RBA_Invoice_Line_Item__c WHERE Invoice_Date__c = THIS_MONTH AND RBA_Participant__c = :participant]; for (RBA_Invoice_Line_Item__c item : itemsForParticipant) { // current month total = current total cost + total cost of line item currentMonthTotals.put(participant, currentMonthTotals.get(participant) + item.Total_Cost__c); } } // Collect all of the unique participant IDs from both // mappings into a list List<Id> participants = new List<Id>(); // First add all previous month unique participants for (Id previous : previousMonthTotals.keyset()) { participants.add(previous); } // ... then add any participants in the current month totals // that aren't in the previous month totals for (Id current : currentMonthTotals.keyset()) { if (!previousMonthTotals.containsKey(current)) { participants .add(current); } } // For each collected participant ID from the previous step, retrieve the participant // record from Salesforce then update their totals if and only if we collected // totals from them for (Id id : participants) { RBA_Participant__c participant = [SELECT Id, Previous_Month_Total__c, Current_Month_Total__c FROM RBA_Participant__c WHERE Id = :id]; if (previousMonthTotals.containsKey(id)) { participant.Previous_Month_Total__c = previousMonthTotals.get(id); } if (currentMonthTotals.containsKey(id)) { participant.Current_Month_Total__c = currentMonthTotals.get(id); } // Collect participant record in a list we will then batch update // once we are done looping participantsToUpdate.add(participant); } // Batch update all updated participants update participantsToUpdate; }
I see this in the debug log:
09:22:32.982|CUMULATIVE_PROFILING|SOQL operations| Trigger.RBA_Invoice_Line_Item_RollupTrigger: line 43, column 1: [SELECT Id, Total_Cost__c FROM RBA_Invoice_Line_Item__c WHERE Invoice_Date__c = LAST_MONTH AND RBA_Participant__c = :participant]: executed 51 times in 279 ms Trigger.RBA_Invoice_Line_Item_RollupTrigger: line 60, column 1: [SELECT Id, Total_Cost__c FROM RBA_Invoice_Line_Item__c WHERE Invoice_Date__c = THIS_MONTH AND RBA_Participant__c = :participant]: executed 50 times in 182 ms
but I'm not sure how/where to move those queries?
- Stephanie_Arce
- November 13, 2013
- Like
- 0
- Continue reading or reply
How to Display Chatter on Visualforce Page
i need Chatter same view on my Visualforce page.Urgent
- BabuKumar
- November 12, 2013
- Like
- 0
- Continue reading or reply
How to show loading image ajax while ajax call in visualforce?
Hi,
can any one send the code pls.
thankns
Ramesh
- santhoshg
- November 12, 2013
- Like
- 0
- Continue reading or reply
rerender not working help plz...
<apex:page name="Queue Criteria" tabStyle="Contact" id="Page" title="Criteria" standardController="Queue_Criteria__c" extensions="QueueCriteriaStdController">
<apex:form id="Form" title="Criteria">
<apex:sectionHeader title="Queue Criteria" subtitle="New Queue Criteria" id="PSHeader"/>
<apex:pageBlock title="Queue Criteria Edit" id="PBlock" tabStyle="Contact" mode="edit">
<apex:pageMessages >
</apex:pageMessages>
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}" />
<apex:commandButton value="Save & New" />
<apex:commandButton value="Cancel" action="{!cancel}" />
</apex:pageBlockButtons>
<apex:pageBlockSection title="Information" columns="2" id="PBSection" collapsible="false">
<apex:inputField value="{!Queue_Criteria__c.Name__c}" required="true"/>
<apex:inputField value="{!Queue_Criteria__c.Contact_Name__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection columns="1" collapsible="false" >
<apex:selectList > value="{!Queue_Criteria__c.Operator__c}" required="true" >
<apex:actionSupport event="onmouseover" reRender="UBV2"/>
</apex:selectList>
<apex:inputField value="{!Queue_Criteria__c.Bounded_Value__c}"/>
<apex:inputField value="{!Queue_Criteria__c.UnBounded_Value1__c}" styleClass="hidden"/>
</apex:pageBlockSection>
<apex:outputPanel id="UBV2" >
<apex:pageBlockSection id="pbs" rendered="{!IF((Queue_Criteria__c.Operator__c=='Between'),true,false)}" >
<apex:inputField value="{!Queue_Criteria__c.UnBounded_Value2__c}" />
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
<script>
function callUBV()
{
var Opr=document.getElementById('Page:Form:PBlock:j_id32:j_id33').value;
}
</script>
</apex:page>
- kannapapi
- November 12, 2013
- Like
- 0
- Continue reading or reply
Sowing more than one row in apex:pageBlock
My Custom Visualforce page.
<apex:page controller="UnapprovedList">
<apex:pageBlock title="Opportunities">
<apex:pageBlockTable value="{!Opportunity}" var="item">
<apex:column value="{!item.Name}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
My Controller
public class UnapprovedList{
private final Opportunity opportunity;
public UnapprovedList() {
opportunity = [SELECT Id, Name FROM Opportunity limit 1];
// the page displays error if i remove limit 1.
//System.QueryException: List has more than 1 row for assignment to SObject
}
public Opportunity getOpportunity () {
return opportunity;
}
}
where is the problem?? i want to show more than one row but when i return multiple row the error pops up..
Any help would be appricated.
- Shanke_Paudel
- November 12, 2013
- Like
- 0
- Continue reading or reply
Bulk api example in C#.net
Hello,
I need bulk api code in C#.net.The developer guide gives the code for client java application.I need it for C#.net.or can i convert the same code to C#.I tried it using IKVM,buit couldnot do it successfully.Please help.
- URVASHI
- October 07, 2013
- Like
- 0
- Continue reading or reply
Bulk API Sample app using C#
Does anyone know how to use Bulk API in C#?
the Web Service API can only update max 200 records at once.
Bulk API can update 10,000 records at once.
I only find sample code using Java.
Thanks.
- Zhen
- October 27, 2010
- Like
- 0
- Continue reading or reply