• ritika@developerforce
  • 100 Points
  • Member since 2011

  • Chatter
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
  • 50

I want to display something different in the subject if a field has a certain value. If its another value, I want display something else. Where am I going wrong here?





recipientType="User" relatedToType="License_Request__c">


How to update the group of fields using batch apex class. I am update the single field using batch apex class. But am unable to update group of fields. Any one help me for solving these. I am follow the class for single field updation 



global class BatchUpdateField implements Database.Batchable<sObject>{
global final String Query;
global final String Field;
global final String Value;
global BatchUpdateField(String q, String f, String v){
Query = q;
Field = f;
Value = v;
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query);
global void execute(Database.BatchableContext BC, List<sObject> scope){  
for(sobject s : scope){

update scope;
global void finish(Database.BatchableContext BC){  
AsyncApexJob a = [Select Id, Status, NumberOfErrors, JobItemsProcessed,TotalJobItems,CreatedBy.Email
from AsyncApexJob where Id = :BC.getJobId()];
string message = 'The batch Apex job processed ' + a.TotalJobItems + ' batches with '+ a.NumberOfErrors + ' failures.';
// Send an email to the Apex job's submitter notifying of job completion.
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {a.CreatedBy.Email};
mail.setSubject('Salesforce BatchUpdateField ' + a.Status);
mail.setPlainTextBody('The batch Apex job processed ' + a.TotalJobItems + ' batches with '+ a.NumberOfErrors + ' failures.');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });  


using the query for execution from systemlog:



string query='select id,website from account';
batchupdatefield batch=new batchupdatefield(query,'website','www.dskvap.com');



 I need a help on using Map on VF page .


public Map<Integer, String> bucketOrderMap{get;set;}


String bucketQuery = 'select Id, Name, Tutorial_Bucket_Unique_Name__c, Sort_Order__c from Tutorial_Bucket_Order__c where Name like \''+ tCategory.getName() +'\'';// and sort_order__c >='+ (currentBucket.sort_order__c - 1) + ' and sort_order__c <= '+currentBucket.sort_order__c + 1 ;       


bucketOrderMap = new Map<Integer, String>();               

for(Tutorial_Bucket_Order__c  curr:Database.query(bucketQuery))  {           

bucketOrderMap.put(Integer.valueOf(curr.sort_order__c), curr.Tutorial_Bucket_Unique_Name__c);     



ON VF=========



  <apex:repeat value="{!bucketOrderMap}" var="c">         

          <apex:outputLabel value="{!c.Label}" />                     

          <!-- <li id="buck_{!c.}">{!c.Label}</li> -->               




In Vf page i got prob. can any body help me how to do it on this withour <apex:pageblock table>




  • August 30, 2011
  • Like
  • 0




In the Contact page, I have replaced the New button on Opportunity related list with Cusotm button (Source is URL).

When I create an Opportunity from Contact, The Acount field of Contact is prepopulated . I have one more Account lookup field in Opportunity. I just want to clear the standard Account lookup field of opportunity and want to prepopulate the custom account lookup field.


I fetched HTML id and populated the Account Name in custom lookup field in Opportunity but how to clear the standard Account lookup field in Opportunity (I don't want to mention any values in standard account lookup field?


Please help me to get a solution .


Thanks in advance...





My requirement is to restrict login hours, but through Apex Code. Unable to locate where is the profile based login hours saved in salesforce.

Please help if you have any information, or any other way by which I can restrict a profile from Logging in (Something like Salesforce Maintenance Notice) for some time and then oepning them up again.




Hi there,


I'm running the following scenario:

I have a Mobile Hybrid App connected to my org in SF. This app uses REST services to get data from Salesforce.

I found the way to get Images as Attachments from the SF using a custom Apex REST (wich returns the Blob Body of the Attachment, encoded in base64 format) and i'm currently displaying those images in my app.


I uploaded a PDF file and a PPT to Salesforce Document, and want to access them by using my App.

Then i created an Apex REST service to return the Body in base64 format..



1) Is it possible to display that base64 representation of PDF in my App (HTML5)?

2) Can i use the base64 rep to store a file (by using Phonegap FileWriter) in my device and then access it from external app?

3) Is there a way to directly display the document without prompting for salesforce login?


Thanx in advance for your support..

  • April 25, 2012
  • Like
  • 0



In apex, How can we determine OWD setting (Org Wide Defaults) for a particular object if we already know object name?




  • February 24, 2012
  • Like
  • 0

Hi Guys,


My requirement is like every day i have to run an apex class in such a way that,

I have to fetch all the updated contacts from the salesforce and i have to put in a file in specific path.

So that datawarehousing guys can access.


Will it possible???? than how????


Can anybody solve my problem.(if possible send me the code)


it is very urgent please.


Thanks In advance.


  • February 22, 2012
  • Like
  • 0

global class batch_emailreport implements Database.Batchable<sObject>, Database.Stateful
global String query;
global boolean istest;
global Database.QueryLocator start(Database.BatchableContext BC)
return Database.getQueryLocator(query);

global void execute(Database.BatchableContext BC, List<sobject> scope)
for(sObject s : scope)
string htmlbdy;
Contact cont = (Contact) s;
date myDate = date.today();
date weekStart = myDate.toStartofWeek();
date StartOfMonth = myDate.toStartOfMonth();

  • February 21, 2012
  • Like
  • 0

Whenever a custom object record is created an event is created on the calendar


Custom Object Name is Building


Here  is the trigger


trigger AutoEvent on Building__c(before insert) {

  List<Event> lstNewEvents = new List<Event>();

  for (Building__c bul : Trigger.new) {
    Event e = new Event();
    e.StartDateTime = bul.Start_Date__c;
    e.EndDateTime = bul.End_Date__c;
    e.Subject = bul.Building_Event_Type__c;
    e.WhatId=------------------;I want this to be to given to the building name .How can i
    e.WhoId = ------------;     Whom should i refer to can i give it to the owner

  insert lstNewEvents;


Is there any possibility that is event on calendar can be created to multiple invitees at the same time



   I'm somewhat new to VF and am running into a very simple (i assume) issue.  I have created a custom object Member Profile that has a master detail relationship with contacts.


I wrote a trigger that creates a new profile each time a new contact is created, and made sure each contact can have 1 and only 1 profile.


Right now the profile is shown in a related list on the contact page.  I want to create a button that brings the user to the detail page of the member profile.


I created a very simple VF member_profile page here



<apex:page standardController="Member_Profile__c">

<apex:detail relatedList="false"/>



Then I added a custom button to the contacts page simply directing to a URL of....





but when I click on the button, it brings me to a new page and gives me this error


Insufficient Privileges
You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary. 


But if I look at the URL, it doesnt have the id of the member profile, it has the name of the profie.  If i try to add the .id like below




It tells me that that field doesnt exist.


I'm sure that I'm doing something simple and stupid, but its driving me crazy that I can't figure it out.  It seems like such a simple thing to want to have a button navigate to another objects detail page.  PLEASE HELP












I have a working validation rule that has to be updated. Now the validation rule checks that either picklist field is selected or text field has user input (some value)

NOT(ISBLANK(TEXT(PicklistField__c ))),

This validation rule still has to work like this in the most of the cases, but there will be one new condition:
IF Another_Picklist__c has value "ABC",
user may not select PicklistField__c or fill in Text_field__c

So now there is a third field which has to be added to the already existing rule.

If Another_Picklist__c is not "ABC", the old rule should trigger just the way it is triggered right now:
NOT(ISBLANK(TEXT(PicklistField__c ))),

But if Another_Picklist equals "ABC", then user may not select PicklistField or add
value to Text_field.

Makes sense?


This is what I tried to do:

IF(NOT(ISPICKVAL(Another_Picklist__c, "ABC")),

NOT(ISBLANK(TEXT(PicklistField__c ))),



What happens here is that the end of the rule is not working alright. Any ideas what I'm doing wrong here?




I am using a before trigger to update some values of Lead records. When loading Lead records I see that the records are NOT being updated thru the trigger whenever there is an error record in the upload list. If all records gets inserted successfully then the update happens fine but the updates doesnt happen when even one record fails to be inserted as part of the upload.


I checkd the debug logs and the trigger logic is executing fine. At the end of the trigger I see that the values are updated in the corresponding Lead records but the result doesnt have the updated values.


Any clues or ideas?

  • September 14, 2011
  • Like
  • 0

I'm just getting my feet with with learning triggers, so I'm looking for help on code!


We have a custom opportunity field (Opportunity MC--basically like a region and/or area of the company the opportunity is being attributed to) that needs to be updated with the value of a custom field on the user page of the opportunity owner (EU). I've been manually doing this on new opportunities, but it would be nice if this is done automatically, as well as whenever the opportunity owner is changed (which is something not being captured currently). I came up with a formula I could use for a formula field [ TEXT(OwnerLookup__r.EU__c ) ], but I don't want to change the values on closed opportunities, when we used different names for the regions.

Essentially the Opportunity MC field needs to equal the EU field of the opportunity owner whenever a new opportunity is created or when the opportunity owner changes. Thanks for any help!

With standard pages concurrent editing of the same record are detected and responded with following message: "The record you were editing was modified by <user> during your edit session." This is not true for Visualforce page or web service API request (this makes sense):


How do you solve this situation when concurrency is required? Of course, we can leverage standard patterns like versioning...but this would require validation rules/workflow rules or triggers for each object we leverage in Visualforce...I cannot believe there is no standard way, isn't it?


Example how to simulate this:

1. Standard Pages

User A loads one record, like https://na12.salesforce.com/001U0000003MZzI

User B loads the same record in standard page like https://na12.salesforce.com/001U0000003MZzI

User A changes the record and saves.

User B changes as well and tries to save: "The record you were editing was modified by User A during your edit session." CORRECT!


2. Standard Page -> VF Page

User A loads one record in standard page like https://na12.salesforce.com/001U0000003MZzI

User B loads the same record in a VF page like  https://na12.salesforce.com/apex/TransactionTest?id=001U0000003MZzI

User A changes the record and saves.

User B changes the record as well and saves. Record get's saved without any error message! WRONG!

Any ideas appreciated...


Best regards,

  • September 04, 2011
  • Like
  • 0

My application has two profiles, one for Admin and other for Non Admin.


There is a Custom Object which is overriden with Visualforce page.

For Admin profile everything works fine.


In Non Admin Profile, if View Setup and Configuration permission is checked, accessing the above Custom tab and remaining functionality works fine. 


If View Setup permission is unchecked, Insufficient Privileges error message is shown.


Can anyone help me out in resolving this issue?

Note: I even tested by giving all the Custom Object Permissions but no luck.



Message Edited by OnDem Dev on 01-12-2010 10:48 PM
Message Edited by OnDem Dev on 01-12-2010 10:52 PM