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;
}

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.

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.

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}

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.

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..

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

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.

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

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!

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.

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.

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?

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 InProgressError status code: INVALID_CROSS_REFERENCE_KEYError message: In field: members - no CustomField named Custom_Field__c foundObject with id:04s900000037qo4AAA is Error

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 InProgressError status code: INVALID_CROSS_REFERENCE_KEYError message: In field: members - no CustomField named Custom_Field__c foundObject with id:04s900000037qo4AAA is Error

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!

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.

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?

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;
}

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.

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.