• Mayank_Joshi
  • 351 Points
  • Member since 2010

  • Chatter
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 14
  • 125



Can anyone please let me know, how to retrieve database records using IDs in 'IN' clause for a query on a custom object.


The below query
select Id, Name from <customObject>__c gives all records

But, if a where clause is added to filter by Ids, no results are displayed.
For example,
select Id, Name from <customObject>__c where ID in (Set<String>) -> gives no results





I want to convert a lead to opportunity only for sales profile and want the standard functionality for remaining profiles. Is there any way to accomplish this?


any help is greatly appreciated. Thanks in advance.

I have class given below


 when i call this class method in button ,click i got the follwoing error



{faultcode:'soapenv:Client', faultstring:'System.EmailException: SendEmail failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, You have uncommitted work pending. Please commit or rollback before calling out: []

Class.ItineraryEmail.SendEmail: line 79, column 1', }


the class method is 


public string getIB() {

System.debug('Test Flight Request'+listFR);
if(listFR != null && !listFR.isEmpty())
Http h = new Http();
HttpRequest req = new HttpRequest();
HttpResponse res = h.send(req);
result = res.getBody();

if(listOpp!=null && !listOpp.isEmpty())
result = listOpp[0].Confirmation_Email_Content__c;
return result;


please let me know what can i do..


thanks in advace

Hi ,


I am currently using Junction Object(Opportunity Platform Models) into My Opportunity Object as Related List.



In this related List , I am unable to see ' Edit ' Link . I am a System Admin and have all access to this Junction Object .Doing research ,I found out that Changing Standard Name field to AutoNumber causing this issue . So ,by changing Standard Name Field to TEXT from AUTO NUMBER is fixing the issue .


But from Business Perspective we need this Standard Name field as Auto Number . So let us know ,how to give edit perm/link on this Junction Object's Related List (Opportunity Platform Models) under oppotunity Object using Standard AutoNumber Name field .



Please investigate, I know it is a Bug or a limitation .


IMPORTANT : >> In this related list-Opportunity Platform Models ,not showing edit link for records .Only Del Link is available . >> And ,by changing AutoNumber to Text will eventually shows Edit link as well.



Hi ,


I am getting compile time error : Error: Compile Error: Loop variable must be of type Id at line 17 column 39 



trigger Trg_Model on Opportunity_Platform_Model__c (after insert) {

Set<ID> Id1 = new Set<ID>();
For(Opportunity_Platform_Model__c OpMd: trigger.new){

Set<id> Id2 = New Set<id> ();
For(Opportunity Opp :Id1){

set<Id> Id3 = new Set<Id> ();
Set<ID> Id4 = new Set<Id> ();
For(Platform_Model__c Pm :Id2){

For(Opportunity_Platform_Model__c OpMd1:Id4){
if(OpMd1.Platform_Model_Selected__c != Pm.Id){



Mayank Joshi 

Hi ,

I am working on requirement using Many to many relationship ,where I need to update Records under RL of Opptunity(Standard master) from Junction Object .

** Opportunity(Standard Master) >> Opportunity Product Model(Detail/Junction)>>(Master)Platform Model

** Platform Master(Master) >> Platform Model(Detail) 

Based on Platform Master's record on opportunity , i need to make lookup filter on Opptunity Platform Model .So that only Child(Platform Model ) of Platform Master will return through Lookup Filter .

Below is the search criteria :

Platform Model Selected: Platform Master: Platform Name CONTAINS Platform Model Selected: Opportunity: Platform(Formula Field) 

But ,it is showing all records also it is woking with START WITH .But not with EQUAL Operator .

Can we achieve this functionality using Lookup Filters ? 

Mayank Joshi 

Hi ,


Is there any way ,so that I can update my parent account field (eg picklist field) from one of its child account ? I am unable to do so via trigger, at run time I am not able to find for selecting child account ID from where I need to pull records . 


Is this possible ? 


Till now i hve this trigger :


Trigger t on account (after insert) {


set<id> accids = new set<ID> ();

for(account a: Trigger.new) { accids.add(AccountID); }


List<account> Acc = [Select ID from account where AccountID in :accids AND parentID =Null ] ;

// Above query gives me , Account ID that are actual parent account records but how can i find child account at this trigger.new list .


Currently , I am considering for creating trigger on Parent accounts only .



Below Trigger is working fine for single record update and insert . But for Bulk data upload ,it is giving Too many DML statements: 151at Line upsert newrecord; . 


Trigger trg_S2S_Account_Automation on Account(after insert,after update)
  List<PartnerNetworkConnection> connMap = new List<PartnerNetworkConnection>([select Id, ConnectionStatus,               ConnectionName from PartnerNetworkConnection where ConnectionStatus = 'Accepted']);
 for(Integer i =0; i< Trigger.size; i++)
   Account acc = Trigger.new[i];
   String acId = acc.Id;
   for(PartnerNetworkConnection network : connMap)
   String cid = network.Id;
   String status = network.ConnectionStatus;
   String connName = network.ConnectionName;
   String AccountName = acc.Name;
   Boolean Synch1 =acc.Allow_Sych__c;
   if(Synch1==True )
      PartnerNetworkRecordConnection newrecord = new PartnerNetworkRecordConnection();
      newrecord.ConnectionId = cid;
      newrecord.LocalRecordId = acId;
      upsert newrecord;




To resolve ,it I am trying to create a List collection type for PartnerNetworkRecordConnection and below is the trigger and it compiles succesfully . But Trigger is not working to send records via S2S connection .Below is the trigger : 


Trigger trg_S2S_Account_Automation on Account(after insert,after update)

 List<PartnerNetworkConnection> connMap = new List<PartnerNetworkConnection>([select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection where ConnectionStatus = 'Accepted']);
List<PartnerNetworkRecordConnection> newrecord = new List<PartnerNetworkRecordConnection> ( );
for(Integer i =0; i< Trigger.size; i++)
Account acc = Trigger.new[i];
String acId = acc.Id;
for(PartnerNetworkConnection network : connMap)
String cid = network.Id;
String status = network.ConnectionStatus;
String connName = network.ConnectionName;
String AccountName = acc.Name;
Boolean Synch1 =acc.Allow_Sych__c;
if(Synch1==True )
//PartnerNetworkRecordConnection newrecord = new PartnerNetworkRecordConnection();
for(PartnerNetworkRecordConnection networkRecord : newrecord){
networkRecord.ConnectionId = cid;
networkRecord.LocalRecordId = acId;
upsert networkRecord;


Do let me know , on where I am missing . I would like to know ,How to upsert records via s2s using List<PartnerNetworkRecordConnection> as I am need to bulk upsert records via s2s .


Thanks in advance .

Hi Developers,


I am currently stuck with this below trigger : 

trigger trg_ChechForSych on Account (before insert,before update) {

List<Account> acc=[Select Name,Type,Allow_Sych__c from Account where Allow_Sych__c=True];
for(Account a:acc)
insert acc;
else a.addError('There was a problem updating the accounts as Allow sych is not checked');





I have this trigger to fire ,if checkbox = true on account . Basically Account records are flowing through Salesforce to salesforce connection. I want to restrict records based on this checkbox value but it is not working fine and giving error at UI level .


Error:Apex trigger trg_ChechForSych caused an unexpected exception, contact your administrator: trg_ChechForSych: execution of BeforeUpdate caused by: System.DmlException: Insert failed. First exception on row 0 with id 0019000000DjxuSAAR; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]: Trigger.trg_ChechForSych: line 7, column 1 


Need help on this . 


Thanks in advance,

Hi ,


while installing Force.com plugin for eclipse 3.6 . I am continuously receiving Unknown Host: http://www.adnsandbox.com/tools/ide/install/


Any Ideas.


Thanks ,



Hi Team,


I am receiving below error :  


FATAL_ERROR|System.DmlException: ConvertLead failed. First exception on row 0; first error: INVALID_STATUS, invalid convertedStatus: Qualified: []


 I am not sure as this trigger is compiled successfully .I want to create Opportunity as well so I commented out "lc.setDoNotCreateOpportunity(false); " this statement .


Below is the complete trigger :


trigger LeadConvert on Lead (after insert,after update) {
for(Lead myLead : Trigger.new)
   if((myLead.isconverted==false) && (myLead.Status == 'Open - Not Contacted'))
    Database.LeadConvert lc = new database.LeadConvert();
    //lc.setconvertedStatus = 'Qualified';        //Database.ConvertLead(lc,true); 
    Database.LeadConvertResult lcr = Database.convertLead(lc);


Can you help me out ?


Thanks ,

Hi ,


I am currently looking for a way to populate contact's email field value through Lookup using Javascript. 


Also, I am successfully getting values but process is lengthy as follow :

#Created Custom object 

#Storing email from contact into custom object via Trigger 

#Lookup relationship in contact with custom object and updating lookup field via trigger as well .

#Created VF page to select email value though lookup (only to achieve requirement for selecting contact's email via lookup :) .)


But , I guess I could achieve this using JavaScript as well .


This requirement is similar to standard functionality which is available using 'send an email ' button , which gives ' cc ' field to select values through contact lookup and returning emails only .


Any idea , on how to achieve it through JS or another way different from my unique approach .


Many Thanks ,

Hi , I have a below trigger (no compilation Error) .It gives  System.FinalException: SObject row does not allow errors .


trigger trigrnotes on Note (before update) {


List <TriggerOnNotesObject__c> tt =[Select Id , Is_Closed__c from TriggerOnNotesObject__c where Is_Closed__c=True ] ;
List<Note> Ntes = [Select Id , ParentId from Note where ParentId IN : tt ] ;

for (TriggerOnNotesObject__c CstObj : tt ){
if(CstObj .Is_Closed__c) {

for(Note n :Ntes )




Alternatively , i have used (it is working fine but not according to my requirement , atleast it is showing error message )


for (TriggerOnNotesObject__c CstObj : tt ){
if(CstObj .Is_Closed__c) {

for(Note n :Trigger.new )




My requirement is to restrict users from editing Notes for SOject whose field Is_closed is True (checked) .Please Guide me . 


Thanks .

Hi everyone,


I understand the usage and setup  of self service portal (Free) , customer portal (Paid ) service . 


But , what is usage of partner portal ?

>> Is it something ,through which we can related two orgs ?

>> Or we are becoming partners with salesforce.com for sharing records .


I am sorry , but I am unable to find any direct information related to it . But , please explain me the business usage (on why I should go for partner portal setup rather than customer portal? ) 


Many Thanks ,

Mayank Joshi



Trigger : 


public class ContactBulkTest {

public static void ContactBulkMethod(Contact[] conts){
List<Country__c> CountryName = [SELECT Id, Phone_Prefix__c FROM Country__c WHERE Name = :MailingCountry LIMIT 1];

map<String, ID> map_cntry = new map<String, ID>

for(Contact c: conts){




Error recieved :  Error: Compile Error: unexpected token: 'for' at line 9 column 6 


I have some other issues with bulk . But suddenly I am stucked in this issue .




Unable to deploy a visual force page on my salesforce, this is working on the sandbox but it is not working  on the production one.


If this vf page is on force.com(using sites) then do I need to active 'Customer portal from SETUP.

Actually VF page is having Authorization error while i click on button.


Reply soon.


i need to show waiting spinner on button click..help needed.

We're trying to understand what possible types of failures are returned for the Status field in the Login History API (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_loginhistory.htm). 

The documentation only mentions that it can be success or a reason for the failure, however, is it possible to explicitly understand the different types of failure? Based on failure type, we'd like to infer the of the failure. 

For instance, I am not sure if SalesForce does any suspicious login detection. If so and if that is available in the status Status, then if a login was blocked because it was suspicious would be of higher priority than a single incorrect password entry.
I have requirment how to integrate with quckbooks with salesforce
in have a generated wsdl  from quickbook and created a classes from this wsdl now I have stuck for next steps
I am new to this concept integration

Please help me out 

  • September 14, 2015
  • Like
  • 0

Hi All


       Am using Datetime datetype in sfdc my doubt is if i havng 1 string date='' & string time='' here how to store the date&time in Datetime datatype field....





Hi All,

Here is the batch apex for capturing system generated lastlogin date into a custom field.

1.Batch Apex

global class CaptureLastLoginDate implements Database.Batchable<sObject>{

//This is the query that is passed to the execute method. .

String ids = UserInfo.getUserId();
String query = 'SELECT id, LastLoginDate,LastLoginDate__c FROM User ';

global database.queryLocator start(Database.BatchableContext BC) {
return database.getQueryLocator(query);
//close start method
global void execute(Database.BatchableContext BC, List<sObject> scope){
    List<Schema.User> u = new List<Schema.User> ();
    for(sObject s: Scope){
        Schema.User inv = (Schema.User)s;
        inv.LastLoginDate__c= inv.LastLoginDate;
    update u;


    global void finish(Database.BatchableContext sc){


2.Scheduled batch

global class scheduledMerge1 implements Schedulable {
   global void execute(SchedulableContext SC) {
       CaptureLastLoginDate M = new  CaptureLastLoginDate(); 
      scheduledMerge1 pa= new scheduledMerge1();
String cronStr = '0 0 * * * ? *';
 System.schedule('scheduledMerge1 Job', cronStr, pa);


4.Test Class for Batch APex

 Private class LastLogintest
 static testMethod void CaptureLastLoginDate()
String ids = UserInfo.getUserId();

    // Making the assumption that at least one user will match this. Better to assign to list and check that has at least one record.
    Schema.User testUser = new Schema.User();
    testUser=[SELECT id, LastLoginDate,LastLoginDate__c FROM User limit 1];
    // Set it to anything other than LastLoginDate so we can tell it has changed.
   //insert testUser;

    CaptureLastLoginDate captureBatch = new CaptureLastLoginDate();
    // Modify the query here so we only get our one testing user of interest
    //captureBatch.query = 'SELECT id, LastLoginDate,LastLoginDate__c FROM User where Id =:testUser.Id';
    ID batchprocessid = Database.executeBatch(captureBatch,1);

    Schema.User afterBatchUser = [Select Id, LastLoginDate, LastLoginDate__c from User where Id =:testUser.Id limit 1];
    System.AssertEquals(afterBatchUser.LastLoginDate, testUser.LastLoginDate__c);

5.Test Class for scheduled apex

Private class Capturetest{
static testMethod void scheduledMerge()

scheduledMerge pa= new scheduledMerge();
String cronStr = '0 0 * * * ? *';



Note:There were no errors in the code. test class for scheduled apex was running fine.but the test class for batch apex failed.Suggest

This is regarding Lead Conversion.


On clicking convert button on lead page we are taken to another page. I have used a custom button and passed the url as "/lead/leadconvert.jsp?retURL=%2F{!Lead.Id}&id={!Lead.Id}&{!Lead.RecordTypeId}&nooppti=1" 


With that given it checks the option of "Do not create a new opportunity upon conversion." 


At the same time I am also looking an option to pass a parameter in URL where I can disable the option of checking it. I am trying to pass a parameter but its not working.

I tried appending to the exisiting url ----> nooppti.disabled =true


But looks like I am passing in a wrong way. Any ideas!!!

  • December 07, 2013
  • Like
  • 0

Whenever I do bulk api uploads to the object referenced in this code I receive an hundreds of emails and failures with the error:


 System.LimitException: Too many code statements: 200001


any ideas how I can limit/update this apex to prevent this error and allow me once again to upload in bulk.


Trigger entitlementTrigger on Entitlement__c (before insert, before update) {
Map<String, String> YearsMap = new Map<String, String>();
Map<String, String> TermsMap = new Map<String, String>();
Map<String, String> DistrictsMap = new Map<String, String>();
Map<String, String> SchoolsMap = new Map<String, String>();
Map<String, String> RecordTypeMap = new Map<String, String>();
for(Entitlement__c e: trigger.new) {
     YearsMap.put(e.Year__c, null);
     TermsMap.put(e.Term__c, null);
     DistrictsMap.put(e.DistrictID__c, null);
     SchoolsMap.put(e.School__c, null);
     RecordTypeMap.put(e.StudentType__c, null);
List<District_Entitlement_Sheet__c> DESList = [SELECT Id, Term__c, Year__c, District__c, Sheet_Type__c FROM District_Entitlement_Sheet__c WHERE Term__c in: TermsMap.KeySet() OR Year__c in: YearsMap.keySet() OR District__c in: DistrictsMap.KeySet() OR Sheet_Type__c in: RecordTypeMap.KeySet()];
List<Entitlement_Sheet__c> ESList = [SELECT  Id, Term__c, Year__c, School__c, Sheet_Type__c FROM Entitlement_Sheet__c WHERE Term__c in: TermsMap.keySet() OR Year__c in: YearsMap.KeySet() OR School__c in: SchoolsMap.KeySet() OR Sheet_Type__c in: RecordTypeMap.KeySet()];
//Now that we have the lists populated of any potential matches iterate through trigger list and match
for(Entitlement__c e: trigger.new) {
      for(District_Entitlement_Sheet__c des: DESList){
           if(e.Term__c == des.term__c && e.Year__c == des.Year__c && e.DistrictID__c == des.District__c && e.StudentType__c == des.Sheet_Type__c) {
                 e.District_Entitlement_Sheet__c = des.Id;
      for(Entitlement_Sheet__c es: ESList){
           if(e.Term__c == es.term__c && e.Year__c == es.Year__c && e.School__c == es.School__c && e.StudentType__c == es.Sheet_Type__c) {
                 e.Entitlement_Sheet__c = es.Id;



Hi all ,


I have written the trigger on task  , whenever i closed the task i will generated another task after 5 days from the due date ,


But it fire the trigger exactly twice in my salesforce org,


I found that some other workflow make my trigger to fire again , I have also attached the crietria and field update of that workflow below for the reference ,

Evaluation CriteriaEvaluate the rule when a record is created, and any time it’s edited to subsequently meet criteria

Rule CriteriaTask: StatusEQUALSCompleted


Field Update: some date/time field in the task .




trigger TaskforEnrolledStatus on Task (before update) {
Date mydate;
List<Task> tasksupd = new List<Task>();
for(Task tsk: Trigger.new)
Task oldtask=Trigger.oldMap.get(tsk.Id);
Task newtask=Trigger.newMap.get(tsk.Id);

if(newtask.Status=='Completed'&& oldtask.Status!=newtask.Status ){
Account aa=[Select id,Account_Status__c from Account where id=:newtask.whatId];

Task tskupd=new Task(ownerId=newtask.ownerId,whatId=newtask.whatId,Subject='Send11 Letter',Priority='Normal',Status='Not Started',ActivityDate=mydate);





My Question here is like Order of execution on salesforce is trigger and then workflow ,

1.Trigger will fire and create the task when we close one task, and then workflow will fire and update the date/time field and 

How come the trigger will fire again ?.


Thanks in advance

I have callString as detail object for account object


I am trying to retrieve callstrins related account name in below SOQL.


But I couldnt  get it.

please help me in writing the right SOQL



for( Call_String__c doc:trigger.new){
List<Account> AccountList = [Select PDE1__c,Total_Calls_Formula__c,called_by_other__c , OwnerId, Co_Owner__c, Name from Account where name =:doc.Account__r.name ];



Hi, we are a TEAM of 3 are developing a application in dev org. We are not able get the complete access to the app, by creating USERS in an org, wats the Standard way to work in parallel & develop an application with both admin & development work.

Thanks in Advance!



Has anyone come accross this warning when inporting into VS 2010?


"Custom tool warning: Schema validation error: Schema item 'simpleType' named 'FaultCode' from namespace 'urn:fault.partner.soap.com' is invalid. The Enumeration constraining facet is an undelcared prefix."


If so was there a fix?


FYI: this happens when using SSIS and creating a scipt task in VB.net and adding the web refernece (parnter and enterprise).


Kind regards


Can we make Name (Std field) unique?



I want to use Gmail/Google credentials of the users to login into Salesforce. I tried few things but it didn't work. Somebody had suggested to have Google apps Premier account. I need to test before investing.


Is there any free solution ?


Please help.






I  want to create the custom button for updating the field value by means of some condition. 


For an example, If the field name is 'Test', After clicking the custom button, field name should be changed to "Test Updated'


Please guide me for doing this..


Any help is appreciated .





Hi I'm new to apex development,


I'm just trying to get a general idae on the tools available and when to use them.


When do you use the eclipse force.com IDE vs the Developer console?


writting code I assume you do in the IDE.

how about debugging?  

and test runs?  I'm finding I sometimes get errors on tests run in salesforce.com but not in the IDE.

do people generally deploy from IDE or salesforce.com?


Phrased another way,  what do you do in the devloper console, and what do you do in the IDE?



Thanks for any insight..  



HI There,


I am new to Salesforce,  I just want to know if it is possible to update two custom objects using a single custom controller (From Visual Force custom page) ? Is it advisable ? If Yes, please share an example .


And one more thing, how to create a look field in a custom VF page and how to populate the values from a lookup field in a custom object ?


Thanks in adavnce :)




  I recented worte a trigger and tested the trigger which is 100% code coverage. When i am tring to deploy this trriger from sandbox to production it is not getting deployed. I do a outbound from sandbox to production. 


   When i check in inbound in production. I dnt see the trigger to deploy. Please suggest me how to deploy trigger in production




I have a list with multiple elements associated with one name. I want to check only if the email address in the first element is empty - the others I don't care if they are blank. Here is my list:


public List<Opportunity> opportunity {
        get {
            return [SELECT Name, Ashoka_Website_Profile_Link__c,
            (SELECT Engagement_Role__c.Name,
            FROM Opportunity.R00NR0000000UWbWMAW WHERE Role__c='Nominator' AND Engagement_Role__c.Contact__r.Email != NULL ) 
            FROM Opportunity WHERE Id = :oppId];


Originally, I did not use a list but instead just created a new Opportunity object. My code all ran fine. I used this if-statement and for-loop after (pardon the terrible naming, it was not my doing):


        if (opportunity.R00NR0000000UWbWMAW[0].Contact__r.Email != null) {
            addresses = opportunity.R00NR0000000UWbWMAW[0].Contact__r.Email;
            for (Integer i = 1; i < opportunity.R00NR0000000UWbWMAW__r.size(); i++) {
                if (opportunity.R00NR0000000UWbWMAW[i].Contact__r.Email != null) {          
                    addresses += ':' + opportunity.R00NR0000000UWbWMAW[i].Contact__r.Email;


But since replacing my code with the list, my code doesn't work anymore. How then would the syntax look? I suppose first I would need to check if the list is empty in the first place, but after that, how would I check if the email field specifically is empty?

  • July 03, 2013
  • Like
  • 0



We have just deployed some Https Webservice that are certified with SSL through reverse proxy that supports SNI (http://en.wikipedia.org/wiki/Server_Name_Indication).


With the simple Outbound Message it works fine, but with WebserviceCallout or with HttpRequest we got the following error :

-IO Exception: java.security.cert.CertificateException: No subject alternative DNS name matching "Server Name" found.



Do the both mecanisms (OutboundMessage and HttpRequest) have different libraries underneath ?


Thank you,



  • March 18, 2013
  • Like
  • 0