• Deepak Balur
  • NEWBIE
  • 55 Points
  • Member since 2015

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 19
    Replies
I have a custom field on a custom object, the field is a multi-picklist of products. What I want is that when someone chooses those products and then saves for it to trigger a flow that creates a new record (on a related custom object) for each product. Is this possible? 

I know I can do this is apex using split(), and I know you can write apex plugins for flows, just wondering if the list that the class would create can be passed back to the flow to create the records? 

I looked at an example of a lead conversion plugin so I have an idea that it might work, but I just cannot wrap my brain around what I am trying to do to understand how to mix the two together - knowing it IS possible will at least get me started. 
 
Hello,

Im trying to write a SOQL query that will grab one of the Contact object's standard fields "Contact Owner", which is a Lookup(User) field.

The field name is "Owner", but when I try to query

SELECT Contact.Owner FROM Contact

I get an error stating that there is no such field.

How can I grab this field?

Thank you!
Hello Dear,
As we all knew that people are talking Number,Eail,Text is use for External ID.
but i found one option that we can use auto number as Extenal ID.Please Clarify me this.
Hello,

I have written a few triggers for my company's org, all seems to be working correctly except one on Account... It was working for the last few months and just today, I have noticed that it stopped working. There is no error message, it just does nothing.

The code coverage for this code is 100% given the test class is in place.

This is an "After" trigger, in which I have switched to "Before" and again, it works in Sandbox, but does nothing in Production... So I have switched it back to the original state when it worked the first few months after I have deployed it into Production. I have also checked and made sure that all custom validation rules on Accounts and Contacts are mirroring each other between Sandbox and Production.

See code below. Any help or explanation is greatly appreciated!!! Thanks in advance!
 
trigger moveContactsOutOfView on Account (After Update) {
      if(checkRecursive.runOnce()){

  set<String> notAccId = New Set<String>();     
  set<String> accId = New Set<string>();
  List<Contact> conUpdate = new List<Contact>();
  List<Contact> con1Update = new list<Contact>();
  List<AccountTeamMember> d1 = new List<AccountTeamMember>();
  
      for (Account a1: trigger.new){
      if (a1.ID != null && a1.Move_out_of_view__c == true && a1.LastModifiedById != '00500000006xZUv' && a1.LastModifiedById != '00500000006wsIm' && a1.LastModifiedById != '00500000006xdMm' && a1.LastModifiedById != '00500000006wnoE'){
          accId.Add(a1.ID);
          }
      else if(a1.ID != null && a1.Move_out_of_view__c == false && a1.LastModifiedById != '00500000006xZUv' && a1.LastModifiedById != '00500000006wsIm' && a1.LastModifiedById != '00500000006xdMm' && a1.LastModifiedById != '00500000006wnoE'){
        notAccId.add(a1.ID);
        
        }
      }
                                   
  LIST<Contact> cY = [SELECT AccountID, LastModifiedById FROM Contact WHERE AccountID In: AccId];
  LIST<Contact> cN = [SELECT AccountID, LastModifiedById FROM Contact WHERE AccountID In: notAccId];
  List<AccountTeamMember> toBeDeleted =[SELECT ID, LastModifiedById FROM AccountTeamMember WHERE AccountID In: AccId];

       for (Account a1: trigger.new){
            for (Contact c1:cY){
                if (c1.LastModifiedById != '00500000006xdMm' && c1.LastModifiedById != '00500000006wnoE' && c1.LastModifiedById != '00500000006wsIm' && c1.LastModifiedById != '00500000006xZUv'){
                    c1.Move_out_of_view__c = True;
                    conUpdate.add(c1);
                }
            }
            for (Contact c2:cN){
                if (c2.LastModifiedById != '00500000006xdMm'&& c2.LastModifiedById != '00500000006wnoE' && c2.LastModifiedById != '00500000006wsIm' && c2.LastModifiedById != '00500000006xZUv'){
                    c2.Move_out_of_view__c = False;
                    con1Update.add(c2);
                }
            }
       }
          for (AccountTeamMember t1:toBeDeleted){
                if (t1.LastModifiedById != '00500000006xdMm' && t1.LastModifiedById != '00500000006wnoE' && t1.LastModifiedById != '00500000006wsIm' && t1.LastModifiedById != '00500000006xZUv'){
                    d1.add(t1);
                }
          }
    

try{ 
update conUpdate;
}

catch (DMLException e) {
            for (Account con : trigger.new) {
                con.addError(e.getDmlMessage(0));
            }
        }
try{
update con1Update;
}
catch (DMLException a){
	for (Account acc:trigger.new){
		acc.addError(a.getDmlMessage(0));
	}
}
try{
delete d1;
}
catch (DMLException b){
	for (Account acc1:trigger.new){
		acc1.addError(b.getDmlMessage(0));
	}
}
        
        
        
}

}





 
Hi,
I have a requirement, where I need to create a record in Salesforce. Get the ID of the record which got created and then make a webservice call passing this id as one of the parameter. If the webservice call fails, I need to rollback the whole transaction. Is this possible to do?

I tried using Savepoint, but I get the error you have uncommited transactions when I do the callout. Is there a workaround? 
Some forums suggested using @future notations, but I need to rollback my DML operation if the callout fails, so can't make it async. 

Any suggestions will be appreciated. 
 
Hello,

I'm developing an application which use an external webservice and when I call him, I get this error message :
System.CalloutException: Endpoint is not valid

I don't understand what is wrong because if I try this URL in the browser, it works.

This is the endpoint : https://maps.googleapis.com/maps/api/geocode/json?address=+94+Rue+de+Provence+75009+Paris+france&components=country:france&#124;postal_code:75009&language=france

I don't understand why but this endpoint works :
https://maps.googleapis.com/maps/api/geocode/json?address=+94+Rue+de+Provence+Paris+france&components=country:france&language=france

I use the Google's API to normalize addresses and it works if I don't use the postal code or the country in the same time.
Postal code + ountry = doesn't work
Postal code = works
Country = works

I created a remote site in Salesforce.com and it is active : https://maps.googleapis.com

If I enter the endpoint (full, postal code with the country) in the Google browser, it works..

Please help mep, I feel crazy.. :
Hi all - I'm trying to figure out the appropriate way to have a trigger to update a lead's status to "SDR Meeting Booked" if an event activity is created by someone whose user profile ID = 00eE0000000adW0.

Modifying some code I found elsewhere I have the first part down (changing status based off an activity being created), but I'm not sure how to modify this to account for the second piece.

Total developer noob here, so any help is appreciated!
 
trigger changeLeadStatus on Event (before insert, before update) {
    String desiredNewLeadStatus = 'SDR Meeting Booked';

    List<Id> leadIds=new List<Id>();
    for(Event t:trigger.new){
            if(String.valueOf(t.whoId).startsWith('00Q')==TRUE){//check if the task is associated with a lead
                leadIds.add(t.whoId);
            }
    }//for
    List<Lead> leadsToUpdate=[SELECT Id, Status FROM Lead WHERE Id IN :leadIds AND IsConverted=FALSE];
    For (Lead l:leadsToUpdate){
        l.Status=desiredNewLeadStatus;
    }//for
    
    try{
        update leadsToUpdate;
    }catch(DMLException e){
        system.debug('Leads were not all properly updated.  Error: '+e);
    }
}//trigger

 
I have created a custom field in the account table which is populated by a picklist.  I need to query the value of the picklist itself, not the field which it populates. How do I do this? Is there a custom fields object/table I can query? If so, how do I find out the source field's name?
*** Please note, I want to query the source from which I select values for the field, not the custom field itself. ***
 
Hello Everyone,

I have a picklist field value if the user select any values he need to enter the "Fee_Planning_Start_Date__c" and it work fine
I have other validation where Fee_Planning_Start_Date__c should be always greater that Start_Date__c
Can you please help out to fix this?
AND(
OR(
ISPICKVAL(Fee_Planning_Status__c , 'Pending'),
ISPICKVAL(Fee_Planning_Status__c , 'Terminated'),
ISPICKVAL(Fee_Planning_Status__c , 'Suspended'),
ISPICKVAL(Fee_Planning_Status__c , 'Approved')

),
ISBLANK((Fee_Planning_Start_Date__c)),
)
Is there a way I can get all parent accounts who do not have cany child accounts?  Thanks for help.
  • January 16, 2015
  • Like
  • 0
Hi Can anyone please help me.

I  have written a trigger which is working absolutly fine on SANDBOX, but not working on production.

trigger duperror on Sourcing_Tracker__c (before insert) {
    
        
    for(Sourcing_Tracker__c SrcTrc : trigger.new){
    List<Sourcing_Tracker__c> stList=[Select id, CreatedDate, Date_of_Sourcing__c, Date_of_Birth__c, Mobile__c from Sourcing_Tracker__c where Date_of_Birth__c=:SrcTrc.Date_of_Birth__c 
                                          And Mobile__c =:SrcTrc.Mobile__c And Date_of_Sourcing__c= LAST_90_DAYS]; 
      
              
        
        if(stList.size()>0 && SrcTrc.Date_of_Birth__c != Null && SrcTrc.Mobile__c != null){
            system.debug(stList.size());
        SrcTrc.addError('Duplicate Record');
            } 
        }
     }
Hi guys, I would really appreciate if you can help me with this requirement. Is it even possible. Please help!!!
Hi everyone. I am new to APEX and need some help.

I need to update the date field "Last_Reseach_Call__c) on the contact record always when a new task with record type "Log Call" was created. This field update cannot be done via workflow, therefore I am trying to solve the problem with an Apex trigger.

Here is the code I have so far:

trigger UpdateContactLastActivity on Task (after insert, after update)
 {

// The set used to hold the Ids of the Contacts that need to be updated
Set <Id> ContactIds = new Set <Id> ();

// The actual Contacts to save
List <Contact> ContactsToUpdate = new List <Contact> ();

// Now we go through and if we find Tasks that are marked as Research Call, then update the Contact with "Last Research Contact" date
for (Task t : Trigger.new)
{
if (t.RecordType)
{
ContactIds.add (t.Contact);
}
}

// Now have the list of Contacts, fetch the associated Contact records and updatethem
if (!ContactIds.isEmpty () )
{
for (Contact c : [select Id, LastName from Contact where Id in :ContactIds])
{
contact.Last_Research_Contact__c = Today();
ContactsToUpdate.add (c);
}

update ContactsToUpdate;
}
}


I currently cannot save the code as I get an error ЭCompile Error: Invalid field Contact for SObject Task at line 15 column 17".

Could please someone advise where the problem is and how the correct code should look like?

Thanks an advance!
Can anyone please help me in querying those cases having more than 200 child cases.

Need to find those cases having 200 child cases.

Please help...!!!
I've learned something today about the following query:

Id sysAdminProfileId = [select Id from Profile where Name = 'System Administrator' limit 1].Id;

When this query is run as part of a trigger fired by a user whose language isn't English, the query doesn't return a result.  So how can I get a consistent result to this query no matter what language the user is set to?  I really don't want to hardcode in profile Id's.  I also don't want to put in a million "or" statements.

Thanks!!
Hi,

I am getting the error message System.QueryException: List has no rows for assignment to SObject
MY  TRIGGER is as follows:

trigger contactRecOwnerUpdate on Contact (before insert)
{
    // This trigger sets the owner of the contact record to be the same as the
    // owner of the account record
    //
    // Version 1.0    
    
    Map<String, Contact> contactMap = new Map<String, Contact>();
    
    for (Contact contact : Trigger.New) 
    {
        if(Trigger.isBefore)
        {
            if (System.Trigger.isInsert)
            {
                // Find the OwnerID of the account that the contact is going to be associated to
                Account contactAccount = [select OwnerId from Account where Id=:contact.AccountId];

                // Make the contact owner the same as the account
                contact.OwnerId = contactAccount.OwnerId;

                // Insert the OwnerId into the contact record
                contactMap.put(contact.OwnerId,contact);
            }
        }

    }
}


And MY Class  is below:

@isTest
private class TestApexTriggers
{
    static testMethod void apexTriggersUnitTest()
    {
        //Set up user
        Profile supportUser = [SELECT Id FROM Profile WHERE Name='U K Support User'];
        Profile supportUserTL = [SELECT Id FROM Profile WHERE Name='SENIOR MANAGER'];
        User nordicTL = [SELECT Id FROM User WHERE ProfileId=:supportUserTL.Id and Alias ='ball'];
        
        // The alias will change when the correct users are created
        User nordicAgent = [SELECT Id FROM User WHERE ProfileId=:supportUser.Id and Alias ='rbows'];

        // Get a list of all active record types within the system associated to Accounts
        List<RecordType> accRTypes = [Select Name, Id From RecordType where sObjectType='Account'];

        // Create a map between the Account record Type Name and Id for for easy retrieval
        Map<String,String> accountRecordTypes = new Map<String,String>{};
        for(RecordType accRT: accRTypes)
            accountRecordTypes.put(accRT.Name,accRT.Id);

        // Get a list of all active record types within the system associated to Contacts
        List<RecordType> conRTypes = [Select Name, Id From RecordType where sObjectType='Contact'];

        // Create a map between the Account record Type Name and Id for for easy retrieval
        Map<String,String> contactRecordTypes = new Map<String,String>{};
        for(RecordType conRT: conRTypes)
            contactRecordTypes.put(conRT.Name,conRT.Id);

        //Run As nordicTL
        System.RunAs(nordicTL)
        {
            // Test Reseller create
            System.debug('****** START Reseller Test *******');
            System.debug('Expected User: System Administrator');
            System.debug('Current User: ' + UserInfo.getUserName());
            System.debug('Current Profile: ' + UserInfo.getProfileId());
            
            Account resellerAcc = new Account();
            
            resellerAcc.Name = 'Unit Test Reseller1';
            resellerAcc.RecordTypeId = accountRecordTypes.get('Reseller');
            resellerAcc.Reseller_s_Hub_PIN__c = '9999';
            resellerAcc.ShippingStreet = 'Test Street1';
            resellerAcc.ShippingCity = 'Test City1';
            resellerAcc.ShippingState = 'Test State1';
            resellerAcc.ShippingCountry = 'Denmark';
            resellerAcc.ShippingPostalCode = '4700';

            System.debug('******* Trying insert resellerAcc *******');
            insert resellerAcc;
            System.debug('******* Inserted resellerAcc *******');
            
            System.debug('****** END Reseller Test *******');
        }
        
        //Run As nordicTL
        System.RunAs(nordicAgent)
        {
            System.debug('****** START Home Test *******');
            
            System.debug('****** Creating a list of resellers in the system *******');
            // Get a list of all Resellers within the system associated to Contacts
            List<Account> resellersList = [Select Name, Id From Account where RecordTypeId=:accountRecordTypes.get('Reseller')];

            System.debug('****** Creating a map of name, id for the retrieved resellers *******');
            // Create a map between the Reseller Name and Id for for easy retrieval
            Map<String,String> resellers = new Map<String,String>{};
            for(Account resAcc: resellersList)
                resellers.put(resAcc.Name,resAcc.Id);            

            // Test Home create
            System.debug('Expected User: Support User');
            System.debug('Current User: ' + UserInfo.getUserName());
            System.debug('Current Profile: ' + UserInfo.getProfileId());
            
            Account homeAcc = new Account();
            
            homeAcc.Name = 'Unit Test Home1';
            homeAcc.RecordTypeId = accountRecordTypes.get('Home');
            homeAcc.Reseller__c = resellers.get('Unit Test Reseller1');
            homeAcc.ShippingStreet = 'Test Street1';
            homeAcc.ShippingCity = 'Test City1';
            homeAcc.ShippingState = 'Test State1';
            homeAcc.ShippingCountry = 'Denmark';
            homeAcc.ShippingPostalCode = '4700';
        
            System.debug('****** Trying insert homeAcc *******');
            insert homeAcc;
            System.debug('****** Inserted homeAcc *******');
            
            System.debug('****** END Home Test *******');

            // Test Contact create
            System.debug('****** START Contact Test *******');
            System.debug('****** Creating a list of Home accounts in the system *******');
            // Get a list of all Resellers within the system associated to Contacts
            List<Account> homesList = [Select Name, Id From Account where RecordTypeId=:accountRecordTypes.get('Home')];

            System.debug('****** Creating a map of name, id for the retrieved homes *******');
            // Create a map between the Home Account Name and Id for for easy retrieval
            Map<String,String> homes = new Map<String,String>{};
            for(Account homAcc: homesList)
                homes.put(homAcc.Name,homAcc.Id);            

            Contact homeCon = new Contact();
            
            homeCon.AccountId = homes.get('Unit Test Home1');
            homeCon.RecordTypeId = contactRecordTypes.get('Consumer');
            homeCon.Salutation = 'Mr1';
            homeCon.FirstName = 'Apex1';
            homeCon.LastName = 'Unit-Test1';

            System.debug('****** Trying insert homeCon *******');
            insert homeCon;
            System.debug('****** Inserted homeCon *******');
            
            System.debug('****** END Contact Test *******');            
        }
    }
}


 
I have a custom field on a custom object, the field is a multi-picklist of products. What I want is that when someone chooses those products and then saves for it to trigger a flow that creates a new record (on a related custom object) for each product. Is this possible? 

I know I can do this is apex using split(), and I know you can write apex plugins for flows, just wondering if the list that the class would create can be passed back to the flow to create the records? 

I looked at an example of a lead conversion plugin so I have an idea that it might work, but I just cannot wrap my brain around what I am trying to do to understand how to mix the two together - knowing it IS possible will at least get me started. 
 
Hello,

Im trying to write a SOQL query that will grab one of the Contact object's standard fields "Contact Owner", which is a Lookup(User) field.

The field name is "Owner", but when I try to query

SELECT Contact.Owner FROM Contact

I get an error stating that there is no such field.

How can I grab this field?

Thank you!
I need an Account Custom Field to be viewable in the Contact Records for that Account. Would I need to build a formula for this or some other way?
Not sure which category this would fall under so I just picked one!  Thanks in advance for your help.