• Paula Jarvis 4
  • NEWBIE
  • 50 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 15
    Questions
  • 18
    Replies
I have two date fields that track warranty start date and warranty end date. I need to lock these down once they have a value and allow three specific Profiles the ability to edit if necessary. This is what I have so far and it works but I am not referencing the second field (Warranty End date). Thank you for your assistance!

AND(
NOT(ISBLANK(PRIORVALUE( PBSI__Waranty_Start_Date__c ))),
ISCHANGED( PBSI__Waranty_Start_Date__c ),
$Profile.Name <> "Custom Finance",
$Profile.Name <> "Custom Billing Administrator",
$Profile.Name <> "System Administrator")
I have the following Trigger to Update Contact Owner Only when Account Owner Changes however only some of the Contact Owners are being updated. It's not updating any other child records, which is great. I just need to understand why it won't update ALL Contacts on an Account.

trigger Changeownertrigger on Account (after update) {
       
          Set<Id> accountIds = new Set<Id>();
          Map<Id, String> oldOwnerIds = new Map<Id, String>();
          Map<Id, String> newOwnerIds = new Map<Id, String>();
          Contact[] contactUpdates = new Contact[0];
          
          for (Account a : Trigger.new)
          {
             if (a.OwnerId != Trigger.oldMap.get(a.Id).OwnerId)
             {
                oldOwnerIds.put(a.Id, Trigger.oldMap.get(a.Id).OwnerId);
                newOwnerIds.put(a.Id, a.OwnerId);
                accountIds.add(a.Id);
             }

          }
            if (!accountIds.isEmpty()) {
             for (Account acc : [SELECT Id, (SELECT Id, OwnerId FROM Contacts) FROM Account WHERE Id in :accountIds])
                {
                String newOwnerId = newOwnerIds.get(acc.Id);
                String oldOwnerId = oldOwnerIds.get(acc.Id);
                for (Contact c : acc.Contacts)
                {
                   if (c.OwnerId == oldOwnerId) 
                   {
                   Contact updatedContact = new Contact(OwnerId = newOwnerId);
                   contactUpdates.add(updatedContact);
                   }
                }
                 
                }
           }
                update contactUpdates;
    }
I have this trigger that basically works however the results provided in the field are an ID and not an actual pick list value. How can I amend this to get the same lookup value to populate the pick list field when the Lookup field is edited?

trigger EMRSystem on Lead (before insert, before update) {
    { 
        for (Lead a : Trigger.new) 
        { 
            a.EMR_System_1__c = a.EMR_System_Confirmed__c;
        }
    }
}
I need to write a Mailing Address validation rule that only allows two profiles to edit/create a particular record type as well as notifying the User to spell out the Country. I have resorted to two validation rules as follows however I was hoping I could combine them. Any thoughts experts?

AND( 
!OR( 
$Profile.Name = "Custom Data Integrity Officer", 
$Profile.Name = "System Administrator"), 
OR( 
MailingCountry = 'U.S.', 
MailingCountry = 'US', 
MailingCountry = 'USA', 
MailingCountry = 'U.S.A.', 
MailingCountry = 'United States of America' 
))


Second VR:
Contact Validation Rule ~ Salesforce - Enterprise EditionAND(
!OR(
$Profile.Name = "Custom Data Integrity Officer",
$Profile.Name = "System Administrator"),
OR(
ISBLANK( MailingStreet ),
ISBLANK( MailingCity ),
ISBLANK( MailingState ),
ISBLANK( MailingPostalCode ),
ISBLANK( MailingCountry ),
$RecordType.Name = "Customer Contact"
))
 
I have a custom button that requies Users to provide reasons for closing an Account. I would like to omit two specific record types form this Java script so we can update the TYPE of Account. We currently are "stopped" from updating th TYPE field because of the Java scipt. Here is the script:

Account Custom Button or Link: Close Prospect ~ Salesforce - Enterprise Edition{!REQUIRESCRIPT("/soap/ajax/8.0/connection.js") }


var leads = new Array();

leads[0] = new sforce.SObject("Account");
leads[0].id = "{!Account.Id}";

var _return = window.confirm('Are you sure you want to begin closing this Account?\nSelect Yes to start the closing process.');
if(_return)
{



var T = "{!Account.Type_Number__c}";
var curDate = new Date();



if(T == 1)
{
var curDate = new Date();
leads[0].RecordTypeId = "012500000009VUN";
}

else
{
alert("The 'Close Prospect' button is only for Prospect accounts. For Live accounts, please create an 'Archive' record at the bottom of the page and follow the archival steps. You can manually change the 'Type' of the account from Live to Archived.");
}



var result = sforce.connection.update(leads);


if (result[0].getBoolean("success"))
{
// Refresh window
window.location.reload();
}

else
{
alert("Request to close this account has failed. \n \nMake sure that you have filled the minimum information required to edit an Account. You can test this by editing a field and attempting to save the account record. \n\n If you can edit and save the account but still see this error, please contact your Salesforce Administrator.\n\nError code 'Acct_Close_1'");
}


}
I have an Account Validation Rule that locks down a field on the Account. I did not enconter any Syntax errors so Ithought I as good to go until I started testing with a Profile not listed. Only the two Profiles listed should be able to enter AND edit the field referenced in the Rule. Any thoughts how to correct?

AND(
$Profile.Name = "Custom Billing Administrator",
$Profile.Name = "System Administrator",
ISCHANGED( RecurSoft__Billing_Contact__c )
)
I have a VR that requires all Users except for Sys Admin and Data Integrity Officer to enter an EMail Address for a particular Contact Record Type. This VR is not recognizing that Users actually entered an email address. It still blocks the User from saving ther record even though the email address is entered. Here is my VR. Feedback would be appreciated. Thank youDeveloper Community!
AND( 
$Profile.Name <> 'Custom Data Integrity Officer', 
$Profile.Name <> 'System Administrator', 
AND( 
OR( 
ISNEW(), 
ISBLANK(Email), 
AND(RecordTypeId = "012500000009VLe"))))
I have this VR and I only want these Profiles to be able to set the Opportunity Stage = Closed/Won however other Users can still set the Stage = Closed/Won.

Opportunity Validation Rule ~ Salesforce - Enterprise EditionAND(
$Profile.Name ="Custom Sales VP",
$Profile.Name ="Custom Sales Operations",
$Profile.Name="Custom Billing Administrator",
$Profile.Name="System Administrator",
$Profile.Name ="Custom Finance Data Loader",
ISCHANGED(StageName),
TEXT(StageName) = "Closed Won"
)
I need to write a SOSL query to look at the Contact Phone and then look up to a custom Account field called Market (Report_card_segment_c). Would someone please assist? I have this so far and I get an error.


 $search = 'FIND {' . $clid . '} IN PHONE FIELDS '.
  'RETURNING ACCOUNT(OWNER.PHONE)';
 
I need to write a SOSL query to look at the Contact Phone and then look up to a custom Account field called Market (Report_card_segment_c). Would someone please assist?
I created a custom date field on the Account called Account_Last_Activity__c and I want to update it based on the last activity by specific Users. I then want to run a report based on the Last Activtiy and by whom. I got this far on my apex code and received an "unexpected toke" error. I have not been able to include the specific User IDs in the code either. Any help would be appreciated. Thank you!


rigger UpdateAccountLastActivityAccount on Task (after insert, after update) {
    Set<String> whatIds = new Set<String>();
    
    for (Task t : Trigger.new) {
        whatIds.add(t.WhatId);
    }
    
    List<Account> acct = [SELECT Id, Account_Last_Activity__c FROM Account WHERE Id =: whatIds];
    
    Map<String, Task> taskMap = new Map<String, Task>();
    
                }
        }   
    }
         
    for (Account a : acct) {
        if (taskMap.containsKey(a.Id)) {
            a.Account_Last_Activity__c = taskMap.get(a.Id).ActivityDate;
        }
    }
    update acct;
}
I need to exlude wo Account Record types from similar Account Validation Rules. I have this so far but it does not seem to work. Do I need to move the "exclusion" to within/at the beginning of the Val Rule?

ISCHANGED(Type)
&&
NOT(ISCHANGED( Button_Validate__c ))
&&
NOT(ISCHANGED( Validation_Override1__c ))
&&
NOT(ISCHANGED( Validation_Override__c ))
&&
(ISPICKVAL( Type , "Nurture")
||
ISPICKVAL(Type, "Do Not Contact")
)
&&
(
TEXT( Reason_for_Closing_Prospect__c ) = ""
)
&&
NOT(ISCHANGED( Button_Validate__c ))
&&
NOT(ISCHANGED( Validation_Override1__c ))
&&
NOT(ISCHANGED( Validation_Override__c ))
&&
NOT( ISNEW() ) 
&& $RecordType.Name <> "Third Party,Vendor"
I created two new Processes using Process Builder. They both update a check box field when the email is left blank on a Lead or Contact. I now need to update/create new Processes that "unchecks" the box when an email is entered. Can I do this under one flow or do I now need two more?
I would like to creat a Workflow that updates a Custom picklist Field (MRR Territory) based on the Standard State/Province Field. I will have all 50 states to accommodate for in the formula and three territories (East, Central, West). Here is how I started the Rule:
IF(ISPICKVAL(State/Province, "AL"), 
IF(ISPICKVAL(State/Province, "SC"),
(MRR_Territory, (Central))

I keep getting an error message.
I am trying to deploy a change set to PROD and I get the above error. The field that is being referenced in the error is part of a custom object but not related to this code. Any thoughts?
I have two date fields that track warranty start date and warranty end date. I need to lock these down once they have a value and allow three specific Profiles the ability to edit if necessary. This is what I have so far and it works but I am not referencing the second field (Warranty End date). Thank you for your assistance!

AND(
NOT(ISBLANK(PRIORVALUE( PBSI__Waranty_Start_Date__c ))),
ISCHANGED( PBSI__Waranty_Start_Date__c ),
$Profile.Name <> "Custom Finance",
$Profile.Name <> "Custom Billing Administrator",
$Profile.Name <> "System Administrator")
I have the following Trigger to Update Contact Owner Only when Account Owner Changes however only some of the Contact Owners are being updated. It's not updating any other child records, which is great. I just need to understand why it won't update ALL Contacts on an Account.

trigger Changeownertrigger on Account (after update) {
       
          Set<Id> accountIds = new Set<Id>();
          Map<Id, String> oldOwnerIds = new Map<Id, String>();
          Map<Id, String> newOwnerIds = new Map<Id, String>();
          Contact[] contactUpdates = new Contact[0];
          
          for (Account a : Trigger.new)
          {
             if (a.OwnerId != Trigger.oldMap.get(a.Id).OwnerId)
             {
                oldOwnerIds.put(a.Id, Trigger.oldMap.get(a.Id).OwnerId);
                newOwnerIds.put(a.Id, a.OwnerId);
                accountIds.add(a.Id);
             }

          }
            if (!accountIds.isEmpty()) {
             for (Account acc : [SELECT Id, (SELECT Id, OwnerId FROM Contacts) FROM Account WHERE Id in :accountIds])
                {
                String newOwnerId = newOwnerIds.get(acc.Id);
                String oldOwnerId = oldOwnerIds.get(acc.Id);
                for (Contact c : acc.Contacts)
                {
                   if (c.OwnerId == oldOwnerId) 
                   {
                   Contact updatedContact = new Contact(OwnerId = newOwnerId);
                   contactUpdates.add(updatedContact);
                   }
                }
                 
                }
           }
                update contactUpdates;
    }
I have this trigger that basically works however the results provided in the field are an ID and not an actual pick list value. How can I amend this to get the same lookup value to populate the pick list field when the Lookup field is edited?

trigger EMRSystem on Lead (before insert, before update) {
    { 
        for (Lead a : Trigger.new) 
        { 
            a.EMR_System_1__c = a.EMR_System_Confirmed__c;
        }
    }
}
I need to write a Mailing Address validation rule that only allows two profiles to edit/create a particular record type as well as notifying the User to spell out the Country. I have resorted to two validation rules as follows however I was hoping I could combine them. Any thoughts experts?

AND( 
!OR( 
$Profile.Name = "Custom Data Integrity Officer", 
$Profile.Name = "System Administrator"), 
OR( 
MailingCountry = 'U.S.', 
MailingCountry = 'US', 
MailingCountry = 'USA', 
MailingCountry = 'U.S.A.', 
MailingCountry = 'United States of America' 
))


Second VR:
Contact Validation Rule ~ Salesforce - Enterprise EditionAND(
!OR(
$Profile.Name = "Custom Data Integrity Officer",
$Profile.Name = "System Administrator"),
OR(
ISBLANK( MailingStreet ),
ISBLANK( MailingCity ),
ISBLANK( MailingState ),
ISBLANK( MailingPostalCode ),
ISBLANK( MailingCountry ),
$RecordType.Name = "Customer Contact"
))
 
I have a VR that requires all Users except for Sys Admin and Data Integrity Officer to enter an EMail Address for a particular Contact Record Type. This VR is not recognizing that Users actually entered an email address. It still blocks the User from saving ther record even though the email address is entered. Here is my VR. Feedback would be appreciated. Thank youDeveloper Community!
AND( 
$Profile.Name <> 'Custom Data Integrity Officer', 
$Profile.Name <> 'System Administrator', 
AND( 
OR( 
ISNEW(), 
ISBLANK(Email), 
AND(RecordTypeId = "012500000009VLe"))))
I have this VR and I only want these Profiles to be able to set the Opportunity Stage = Closed/Won however other Users can still set the Stage = Closed/Won.

Opportunity Validation Rule ~ Salesforce - Enterprise EditionAND(
$Profile.Name ="Custom Sales VP",
$Profile.Name ="Custom Sales Operations",
$Profile.Name="Custom Billing Administrator",
$Profile.Name="System Administrator",
$Profile.Name ="Custom Finance Data Loader",
ISCHANGED(StageName),
TEXT(StageName) = "Closed Won"
)
I need to write a SOSL query to look at the Contact Phone and then look up to a custom Account field called Market (Report_card_segment_c). Would someone please assist? I have this so far and I get an error.


 $search = 'FIND {' . $clid . '} IN PHONE FIELDS '.
  'RETURNING ACCOUNT(OWNER.PHONE)';
 
I need to write a SOSL query to look at the Contact Phone and then look up to a custom Account field called Market (Report_card_segment_c). Would someone please assist?
I created a custom date field on the Account called Account_Last_Activity__c and I want to update it based on the last activity by specific Users. I then want to run a report based on the Last Activtiy and by whom. I got this far on my apex code and received an "unexpected toke" error. I have not been able to include the specific User IDs in the code either. Any help would be appreciated. Thank you!


rigger UpdateAccountLastActivityAccount on Task (after insert, after update) {
    Set<String> whatIds = new Set<String>();
    
    for (Task t : Trigger.new) {
        whatIds.add(t.WhatId);
    }
    
    List<Account> acct = [SELECT Id, Account_Last_Activity__c FROM Account WHERE Id =: whatIds];
    
    Map<String, Task> taskMap = new Map<String, Task>();
    
                }
        }   
    }
         
    for (Account a : acct) {
        if (taskMap.containsKey(a.Id)) {
            a.Account_Last_Activity__c = taskMap.get(a.Id).ActivityDate;
        }
    }
    update acct;
}
I would like to creat a Workflow that updates a Custom picklist Field (MRR Territory) based on the Standard State/Province Field. I will have all 50 states to accommodate for in the formula and three territories (East, Central, West). Here is how I started the Rule:
IF(ISPICKVAL(State/Province, "AL"), 
IF(ISPICKVAL(State/Province, "SC"),
(MRR_Territory, (Central))

I keep getting an error message.
I am trying to deploy a change set to PROD and I get the above error. The field that is being referenced in the error is part of a custom object but not related to this code. Any thoughts?