• Scott McClung
  • NEWBIE
  • 310 Points
  • Member since 2014

  • Chatter
    Feed
  • 8
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 34
    Replies
Is it possible to use a visual flow to send an email to the opportunity owner advising them that there opportunity is closing in x amount of days?  I know you can do this with the standard workflow function but was just curious if this could be replaced with a flow.

Hey Everyone,

I'm completely new to Salesforce so I apologise for my lack of Apex knowledge in advance, I am signing up to all of the relevant courses as we speak......

I'm having trouble creating a validation rule that makes sure an option from a picklist must be chosen before the stage can be advanced to 'Proposal/Price Quote' stage.

Can anyone help?

 

Would really appreciate any information or suggestions people may have.

Thanks,

Ash

 

 

Hi all!

Trying to make a validation rule on the Lead Object that would throw an error whenever the zip code is not equal to having 5 numbers in it. 

Right now I have this:

LEN(Postalcode)<>5

However, this throws an error whenever the zip isn't filled out - I need it to trigger whenever that zip code field is filled out but isn't 5 numbers.  

Thanks for any help you can give!
How can I modify an existing page layout so that the page layout assigned to managers display

Cases
Acitivity History
Notes and Attachments
Partners

If the page layout is assigned to sales rep those above mentioned related lists should not be display . Is there any way to achieve this ?
Hello, I'm totaly new to the salesforce development world, so maybe this is not the correct question to make. 
I'm doing a quick app to try to understand how to develop on salesforce and I came to a moment where I don't know what to do. I need 2 different user to be able to choose a value from a picklist. The thing is that one user should be able to choose more than one value, an the other only one.
I tried to solve this by creating 2 different profiles, and try to create a record type, but the problem is that with the record type I can limit the values shown in the picklist, but can't change from a "Only one" selection to a Muptiple selection.
Maybe my way of thinking the solution is wrong, but is there a way of doing this? If not, how should be my way of thinking the solution to this?
Thank you in advance.
Hi friends,
please help me. What is wrong with the code?

listProduct2 = [SELECT id, name, tariff__c from product2 where tariff__c =: tariffChosen];
        for (product2 prod : listProduct2) {
            List<OpportunityLineItem> listOpportunityLineItem = new List<OpportunityLineItem>();
           System.debug('The products : '+prod);
            OpportunityLineItem oppliToInsert = new OpportunityLineItem(
                OpportunityId = myOpportunity.Id,
                Product2Id = prod.id);  // ?????????????
   listOpportunityLineItem.add(oppliToInsert);
         }
Hi all,

How to call a JavaScript function from a Visualforce page that is embedded in the page layout as a section to the home page custom component?

The JavaScript executes when the VF page is not embedded in the pagelayout but the same will not work when we add the VF page to the page layout.

VF page --> this page is embedded in the Opportunity page layout.

<apex:page standardController="opportunity">
<script>
displayMessage();
</script>
</apex:page>

Custom Component (This code is available in the sidebar)

<script>
function displayMessage()
{
alert("hello");
}
</script>

Any help would be greatly appreciated.

Regards,
Raghu
Hey there,

I have Accounts and Accounts has a custom child object named Services__c. Services__c, are added to the account. I was wondering if it is possible to write a validation rule which would prevent the same service (which is picked through a picklist, which auto-updates a hidden lookup field) from getting added twice to an account. 

If more explanation is neededd, please do not hesitate to ask.

Thankyou
Hello all,
I'm getting the error in subject when I try to run this code:
@auraEnabled(cacheable=true)
public static void Equalize(string campaignsStr){
    string[] campaigns = (string[])JSON.deserialize(campaignsStr, list<String>.class);

    //Will hold the opportunities to update
    list<opportunity> updates = new list<opportunity>();

    //Will keep track of user ids and opp counts
    map<string, integer> owners = new map<string, integer>();	//String = OwnerID	Integer = opp count

    list<opportunity> opps = [SELECT Id, OwnerId FROM Opportunity WHERE Primary_Campaign_Filter__c IN :campaigns LIMIT 9999];
    System.debug('opps size: ' + opps.size());

    //Initializing the values of the owners map
    for(opportunity o: opps){
        if(owners.containsKey(o.ownerID)){
            owners.put(o.ownerID, owners.get(o.ownerID) + 1);
        }
        else{
            owners.put(o.ownerID, 1);
            System.debug('Adding owner ' + o.ownerId);
        }
    }

    //For each opportunity, if that owner already has more than the average,
    //give it to the person with the lowest opportunity count.
    integer threshold = opps.size()/owners.size() + 2;
    for(opportunity o: opps){
        if(owners.get(o.OwnerID) > threshold){
            string lowest = GetLowest(owners);
            owners.put(o.OwnerID, owners.get(o.OwnerID) - 1);
            owners.put(lowest, owners.get(lowest) + 1);
            o.OwnerID = lowest;
            updates.add(o);
        }
    }

    //PULL MY DEVIL TRIGGER
    System.debug('updates size: ' + updates.size());
    try{update updates;}
    catch(exception e){
        System.debug('exception: ' + e);
    }
}
I have seen solutions for Lightning Components (like https://developer.salesforce.com/forums/?id=906F0000000917DIAQ), but none that apply to Lightning Web Components. This is part of a component that has multiple other apex methods being called, and they all update fine.

Can anyone help me identify where the problem is?

Thanks!
 
Hi,

I just created a visual workflow and tried to activate but couldn't get the "Activate" button anywhere.
Could some one please guide me.

Thank YouActivate button missing in Visual Workflow
Hi, I developed a workflow rule that also includes an Email Alert.  I know that the workflow rule is triggering because it also does a Field Update that IS functioning as desired.

However the emails aren't firing.  About 6 months ago I had a similiar problem, and SF tech support fixed it for me, it had something to do with some security setting somewhere, but I can't find a record of that at present.

Any advice appreciated!  Cheers.
Hi all,

I was wondering if you can create a Workflow when a field in a picklist is changed at all? If the record is altered I want an email to fire to a particular person.

Many thanks.
I need to implement the following scenario:-

All the cases which have been put on hold should be reassigned to a particular queue. I need this to run every 15 days. I am thinking of addressing this by creating a Time Dependent workflow that would be evaluated:-

1) When a record is created, and any time it’s edited to subsequently meet criteria.
2) Every15 days after Case: Last Modified Date.

Is this the correct way OR do I need to implement this programatically?

How can I take care of my existing cases which are created before the workflow is created?
Hi There, 

I have a lead provider who wants to post data to me on leads via HTTP Post, however, I don't know the easiest way of doing this. I'm not a develper myself and don't know the easiest way of doing this.  I do have all the posting variables from the lead provider and have those fields created in my salesforce account, however, I don't know the easiest way of creating the posting url to provide him and test delivery. Any help will be much appreciated. 
Is it possible to use a visual flow to send an email to the opportunity owner advising them that there opportunity is closing in x amount of days?  I know you can do this with the standard workflow function but was just curious if this could be replaced with a flow.

Hey Everyone,

I'm completely new to Salesforce so I apologise for my lack of Apex knowledge in advance, I am signing up to all of the relevant courses as we speak......

I'm having trouble creating a validation rule that makes sure an option from a picklist must be chosen before the stage can be advanced to 'Proposal/Price Quote' stage.

Can anyone help?

 

Would really appreciate any information or suggestions people may have.

Thanks,

Ash

 

 

When trying to call an APEX class from any flow in my DE org I get an error message:

A fault occurred while executing your script:
Data Not Available: The data you were trying to access could not be found. It may be due to another user deleting the data or a system error. If you know the data is not deleted but cannot access it, please look at our support page.

I'm actually getting the error whenever a flow is trying to invoke APEX, even when I use an example that was posted on a salesforce.com blog. Does nybody have any ideas?
Every now and then I get a ___ error on this trigger (on Line #7):

trigger HandoffToISRLead on Task (after insert) {

Map<Id,Id> LeadsToUpdate = new Map<Id,Id>();


for (Task t: Trigger.new) {
    if(t.Subject.startsWith('Handoff to ISR') && t.WhoId != NULL && String.valueOf(t.WhoId).startsWith('00Q'))
    
    LeadsToUpdate.put(t.WhoId, NULL);
    }

List<Lead> LeadsToHandoff = [SELECT Id, Last_ISR_ID__c, ISR_Handoff_Counter__c, LeadSource FROM Lead where Id IN:LeadsToUpdate.keyset()];

if (LeadsToUpdate.keyset().size()>0){

for (Lead l: LeadsToHandoff) {
    l.SD_Pipeline__c = true;
    if(l.ISR_Handoff_Counter__c != NULL){
    l.ISR_Handoff_Counter__c = l.ISR_Handoff_Counter__c + 1;}
    else{l.ISR_Handoff_Counter__c = 1;}

    if(l.Last_ISR_ID__c != NULL){
    l.OwnerID = l.Last_ISR_ID__c;
    }
    else if(l.LeadSource == 'Partner/Vendor'){l.OwnerID = '00530000009b58p';}
    else{l.OwnerID = '00530000009sb4g';
}
    }
    update LeadsToHandoff;
}
}

Here is some of the recent debug code:

16:16:53.139 (139810822)|CODE_UNIT_STARTED|[EXTERNAL]|01q30000000a8Hi|HandoffToISRLead on Task trigger event AfterInsert for [00T3000002gcWfr, 00T3000002gcWfs]
16:16:53.139 (139836969)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:12
16:16:53.139 (139876331)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:12
16:16:53.139 (139893603)|VARIABLE_SCOPE_BEGIN|[1]|this|HandoffToISRLead|true|false
16:16:53.139 (139954648)|VARIABLE_ASSIGNMENT|[1]|this|{}|0x7e3d9e08
16:16:53.139 (139977350)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:12
16:16:53.139 (139987725)|VARIABLE_SCOPE_BEGIN|[1]|this|HandoffToISRLead|true|false
16:16:53.140 (140005443)|VARIABLE_ASSIGNMENT|[1]|this|{}|0x7e3d9e08
16:16:53.140 (140012249)|STATEMENT_EXECUTE|[1]
16:16:53.140 (140015277)|STATEMENT_EXECUTE|[3]
16:16:53.140 (140025872)|HEAP_ALLOCATE|[3]|Bytes:4
16:16:53.140 (140061801)|VARIABLE_ASSIGNMENT|[3]|this.LeadsToUpdate|{"serId":1,"value":{}}|0x7e3d9e08
16:16:53.140 (140138730)|HEAP_ALLOCATE|[6]|Bytes:5
16:16:53.140 (140167629)|VARIABLE_SCOPE_BEGIN|[6]|t|Task|true|false
16:16:53.140 (140589412)|VARIABLE_ASSIGNMENT|[6]|t|{"RecordTypeId":"01230000001dnNMAAY","Event_Completed__c":false,"CurrencyIsoCode":"USD","LastModifiedById":"00530000009beV7AAI","OwnerId":"00530000009beV7AAI","LastModifiedDate":"2014-05-14T23:16:53.000Z","ActivityDate":"2014-05-14T00:00:00.000Z","IsRecurrence":false,"Priority":"Normal","IsArchived":false,"Status":"Not Started","IsClosed":false,"IsVisibleInSelfServi (2 more) ...":false,"qbdialer__SMSReminde (4 more) ...":false,"DB_Activity_Type__c":"Other","IsReminderSet":false,"SystemModstamp":"2014-05-14T23:16:53.000Z","CreatedById":"00530000009beV7AAI","CreatedDate":"2014-05-14T23:16:53.000Z","IsDeleted":false,"Id":"00T3000002gcWfrEAE","IS_Response__c":false}|0x589b05d7
16:16:53.140 (140602741)|STATEMENT_EXECUTE|[6]
16:16:53.140 (140623278)|HEAP_ALLOCATE|[7]|Bytes:14
16:16:53.140 (140738987)|HEAP_ALLOCATE|[7]|Bytes:41
16:16:53.140 (140899452)|FATAL_ERROR|System.NullPointerException: Attempt to de-reference a null object

Trigger.HandoffToISRLead: line 7, column 1
16:16:53.140 (140913883)|FATAL_ERROR|System.NullPointerException: Attempt to de-reference a null object

Trigger.HandoffToISRLead: line 7, column 1
16:16:53.140 (140989867)|CODE_UNIT_FINISHED|HandoffToISRLead on Task trigger event AfterInsert for [00T3000002gcWfr, 00T3000002gcWfs]
16:16:53.140 (140997965)|EXECUTION_FINISHED


I tried looking for the 2 tasks in the debug code, but received this error when trying to access them:

Data Not Available
The data you were trying to access could not be found. It may be due to another user deleting the data or a system error. If you know the data is not deleted but cannot access it, please look at our support page.

 

What's the best way to fix this? Feel like I'm missing something simple.

Hi all,

I'm trying to find out if I can use a Trigger to prevent the conversion fo a lead (upon certain conditions that I won't detail here).

My intuition was to use a Before trigger and check the field Lead.IsConverted.
If True, I run my validation and return an error when they fail.
If False I just let the operation complete.

The problem is I'm not sure that the field IsConverted will already be set to true when I use a Before Trigger.

Is there a way to check?
  • May 14, 2014
  • Like
  • 0
Hi all!

Trying to make a validation rule on the Lead Object that would throw an error whenever the zip code is not equal to having 5 numbers in it. 

Right now I have this:

LEN(Postalcode)<>5

However, this throws an error whenever the zip isn't filled out - I need it to trigger whenever that zip code field is filled out but isn't 5 numbers.  

Thanks for any help you can give!
Hey everyone,

I received a request to remove the chatter alerts on accounts that say "[NAME] updated this account by converting a lead." I'm sure you've received that complaint before as well, since those alerts can't be removed via the admin setup.

User-added image

So I tried creating a trigger to delete those alerts when a lead is converted, but I get an error that says I can't filter by the FeedItem's "Body" field, which as far as I know, is the only way to distinguish these types of alerts. Here is the trigger I tried writing:

public class ClassDeleteConvertAlerts{
    
    public void deleteAlerts(List<Lead> leads,Map<Id,Lead> oldLeads){
        
        Set<String> convertedLeads = new Set<String>();
        List<FeedItem> feedItemsToDelete = new List<FeedItem>();
        
        FOR(Lead l : leads){
            IF(l.IsConverted == TRUE && oldLeads.get(l.Id).IsConverted == FALSE){
                convertedLeads.add(l.Id);
            }
        }
        
        IF(convertedLeads.size() > 0){
            FOR(FeedItem item : [SELECT
                                   Id,Title
                               	 FROM
                                   FeedItem
                                 WHERE
                                   Body LIKE '%updated this account by converting a lead%']){

                                                       feedItemsToDelete.add(item);

                                                  }
        					                                  
         IF(feedItemsToDelete.size() > 0){
            DELETE feedItemsToDelete;
        }
        
    }

}

Is there any way to accomplish what I'm trying to do? Can I delete feeditems based on what's in the Body?

Thanks!
-Greg
Hello.

I have a table containing over 270,000 objects.  When I try to insert more objects, I get an error saying "Non-selective query against large object type" from a before-insert trigger that I have on that table.

The before-insert trigger is to prevent duplicate rows being inserted based on a formula field:

trigger XBeforeInsert on X__c (before insert) {

	Map<String, X__c> xs = new Map<String, X__c>();
	
	for (X__c x: Trigger.new) {
			xs.put (x.Unique__c, x);
	}

	for (X__c x: [ Select Id, Unique__c, RecordTypeId
				 From X__c
				  Where Unique__c in :xs.keySet()]) {
		// add some error message
	}	
}
The field Unique__c is not indexed.  Would getting Salesforce to add a custom index on that field make a difference?  Alternatively, is there some other way to achieve this?

Thanks,

Carl

  • May 14, 2014
  • Like
  • 0
Hi,

What is the formula to create a report that searchs for a date field + OR - a given number of days (7) in thiscase.

I know I could do this from two reports but that seems incredilbly clumsy to me.

Thanks in advance.
I just created an architecture for central trigger processing based on Dan Appleman's book, 'advanced apex programming'.  It works fine unless I use the standard feature, imprort custom object where the import has a mix of inserts and updates based on an external ID.  If the list is all inserts or all updates the trigger fires for all records.  When it is a mix of the two it only fires for the inserts.  The updates will have their records updated as the spreadsheet says but the trigger won't fire.

Central Dispatch class
--------------------------
<pre>
public class Dispatch{
   
    Public Interface ITriggerEntry{
        void MainEntry(Boolean IsUpdate, Boolean IsInsert,
                       Boolean IsDelete, Boolean IsExecuting,
                       Boolean IsBefore, Boolean IsAfter,
                       LIST<sObject> NewList, Map<Id,sObject> NewMap,
                       LIST<sObject> OldList, MAP<Id,sObject> OldMap);
       
        void InProgressEntry(Boolean IsUpdate, Boolean IsInsert,
                             Boolean IsDelete, Boolean IsExecuting,
                             Boolean IsBefore, Boolean IsAfter,
                             LIST<sObject> NewList, Map<Id,sObject> NewMap,
                             LIST<sObject> OldList, MAP<Id,sObject> OldMap);
    }
   
    Public Static ITriggerEntry activeclass = null;
   
    Public Static Void FrontDoor(String TriggerObject, Boolean IsUpdate, Boolean IsInsert, Boolean IsDelete, Boolean IsExecuting, Boolean IsBefore, Boolean IsAfter, LIST<sObject> NewList, Map<Id,sObject> NewMap, LIST<sObject> OldList, MAP<Id,sObject> OldMap){       
        If(activeclass != null){
            activeclass.InProgressEntry(IsBefore,IsDelete,IsAfter,IsInsert,IsUpdate,IsExecuting,NewList,NewMap,OldList,OldMap);
            return;
        }
               
        If(TriggerObject == 'CPM_Contract__c'){
            IF(IsAfter && (IsInsert || IsUpdate)){
                activeclass = new CPMeContractProcess();
                activeclass.MainEntry(IsUpdate, IsInsert, IsDelete, IsExecuting, IsBefore, IsAfter, NewList, NewMap, OldList, OldMap);
            }
        }
    } 
}
</pre>