• SSimion
  • NEWBIE
  • 10 Points
  • Member since 2019
  • Salesforce Administrator

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 9
    Replies
Hi All,

I have a process that maps a custom field from the Lead Object to a standard field on the Account Object and it also populates a lookup on the Opportunity, upon conversion.

It works perfectly fine, but I want it now to only map the value, if the Account is a new Account rather than existing.
  • The process fires when a record is created or edited.
  • Nod Criteria - conditions are met:
             [Lead].IsConverted = TRUE
  • Update Records: [Lead].Converted Account ID - meet all conditions:
           Condition: 1. Created Date = DATETIMEVALUE([Lead].ConvertedDate])

Update Records: standard field = [Lead].custom_field__c
  • Update Records: [Lead].Converted Opportunity ID
Contact = [Lead].ConvertedContactId

The PB doesn't populate the standard field on Account, because of the condition.

Any help will be much appreciated.

Thanks.
Hi All,

I've created a lookup field from the Opportunity to the custom Object, in order to reference different values from the custom Object on the Opportunity. The custom Object holds the products lines from another system. For one Opportunity in Salesforce, there can be up to 2 Orders in the other system. The product lines are being created as separate lines on the custom object.

I want to be able to show on the Opportunity in Salesforce:
  • the default Order number from the other system
  • the second Order number from the other system, if it exists. (there is a checkbox on all the product lines, if they are related to the second Order)
  • change pick-list value on the Opportunity, based on the values of a field on the related records from the custom Object.
What I have tried so far:
  • Trigger to update the order numbers from the other system - in two separate fields on the Opportunity in Salesforce (custom field 1 and custom field 2)
  • PB on the custom object - to change the pick-list values, but the process failed when trying to check if the related records are related to the same Opportunity number in Salesforce). the lookup field not being populated, so I have tried to create a trigger to populate the lookup with the id of one of the related records and create the custom field 1 and custom field 2 as formula fields, instead of using trigger.
Custom field 1:
IF(Custom_Object__r.Check_Box__c = FALSE, Custom_Object__r.custom_field1__c, null)

Custom field 2:
IF(Custom_Object__r.Check_Box__c = TRUE, Custom_Object__r.custom_field2__c, null)

But it doesn't fulfill the requirement, because the Opportunity in Salesforce will always have a default order from the other system, so depending what id I am filling in the lookup, the formula doesn't always populate the default order number, also the second order number needs to be populated, when the checkbox on the related records is true.

Any help will be appreciated on how it's best to achieve the requirements.

Thanks a lot.
Hi All,

I have a Process Builder and a Validation Rule on the Opportunity Object.

The Validation Rule is meant to stop the users from modifying an Opportunity once Closed Won, apart from Admins.
 
AND
(ISPICKVAL(PRIORVALUE(StageName),"Closed Won"), CASE($Profile.Name, 
"ProfileName1",1, 
"ProfileName2",1, 
0)=0 
)

And the Process Builder is checking if "[Opportunity].IsClosed = TRUE, and updates the Close Date = TODAY().

Error message:
 
> The flow tried to update these records: null. This error occurred:
> FIELD_CUSTOM_VALIDATION_EXCEPTION


Both the Process Builder and the Validation Rule work fine, but activated separately.

Is there a way to stop the users from modifying the Closed Won Opportunity, but allow the process to change the Close Date for the users?


Thanks.
Hi guys,

I have a custom object - Object 1 and the Opportunity object. I've created a lookup field from the Opportunity to Object 1 and I am working on a trigger to populate the id of one related record into the lookup field, in order to reference some of the values, back on the Opportunity.

The related records on the Object 1 are being created first (as part of an integration) and one Opportunity, could have 1+ related records, but only one related record will be populated in the lookup field.

Once the lookup field is populated through the trigger, I want to be able to change the picklist value on the Opportunity based on a text field on Object 1. 

I have tried to change the picklist value using PB or Workflow, but it didn't work.

The scenario is to change picklist value to:
  • "A" - if the text field contains "a", but it might also contain "b", "c" or "d", but it should definitely contain "a".
For each picklist is a comibination of the above.

For one picklist value though:
  • "E" - if the text field contain 2 or more of the "a",  "b", "c" "d" combination.
Considering the Opportunity can have more than one related record, I am not sure if it's possibe to do this through a formula - to check all the related records.

Workflow I have tried for one scenarion:

AND (

OR (

ISNEW()
ISCHANGED(Object_1__r.text_field__c)),

CONTAINS(Object_1__r.text_field__c, "a" && ("b" || "c" || "d"))

)

and field update:  picklist value = A

but the fuction ISCHANED cannot be refrenced for my field.

Any help or ideas will be much appreciated.


Thanks.
Hi All,

I hope you're all well.

I have a custom object - Object 1 and the Opportunity object. I've created a lookup field from the Opportunity to Object 1 and I want to be able to populate the id of a related record into the lookup field, in order to reference some of the values, back on the Opportunity.

The related records on the Object 1 are being created first (as part of an integration), so I want my trigger to fire after the records are created, or modified.

One Opportunity, could have 1+ related records.

In order to differentiate for each Opportunity, those records are related to, we have two custom fields, field 1 on the Opportunity that contains an unquie number and another custom field on the Object 1 that contains the same unquie number the Opp has.

I want my trigger to fire everytime the related records are created and populate the id of one of them into the lookup, so I can reference different values from the Object 1.

This is what I have attempted to build so far, but I am not having much success... so a little bit of help, it's much appreciated. 

I built the trigger on the custom object 1, but I am not sure if  this is correct...
 
ttrigger UpdateLookup on Object_1__c (after insert, after update){
for (Object_1__c obj: trigger.new){
    Obj1Ids.add(obj.id);
}

Map <Opportunity> matchingIdsMap = new Map <Opportunity> ();

for (Opportunity obj: [Select Id, field_1__c from Opportunity, where id in:ObjIds]){
matchingIdsMap.put(Opportunity.id, Opportunity);
}

List <Opportunity>OpportunitiesToUpdate = new List <Opportunity> ();

for (Object_1__c obj: trigger.new){

if (matchingIdsMap.get(obj.id) ! = null)



{

   matchingIdsMap.get(obj.id).Object_1__C = ObjIds;

   OpportunitiesToUpdate.add (matchingIdsMap.get(ObjIds));

}

update OpportunitiesToUpdate;
}

Thanks a lot.
 
Hi guys,

I hope you're all well.

We have an integration with another system, that's sending the OLIs into a Custom Object + Custom fields in Salesforce. I want to be able to show the value from a field from the custom Object on the Opportunity Object. There was no relationship between the 2 Objects, so I have created a Lookup field, so the relationship is now a lookup relationship one to many. One Opportunity can have multiple OLIs on the Custom Object. I have tried with a cross object forma field on the Opportunity Object: customobject__r.custimfield__c, but it only works if I am populated the Lookup field, which it's not what I want to achieve. I just want to transfer the value over, without having to populate the lookup (Yes, I know. It works as designed).
I have tried a workflow field update and check if there is value on the custom field on the custom object to populate the custom field on the Opportunity, but it doesn't populate the value.

Is this only achievable with Trigger?

Any help is much appreciated.

Thanks a lot.
Hey guys,

We are in Lightning and we will soon have an integration built between Salesforce and another system.

Salesforce will only hold the pipeline information, and the other system will push all the product line information back into Salesforce, to a custom object/custom text fields.

What will be the best practice/approach here, please? In order to create the product lines in Salesforce? To create an Apex Trigger to get the info from the fields and generate the OLIs?

Do I have to have all the products set up in Salesforce as well, for the trigger?


Thanks in advance.
S
Hi guys,

I am using Lightning and its standard functionality of adding products on an opportunity. I have created a custom field (let's call it X) on the Opportunity Product that it's a Lookup field to a custom object (not ideal)

On the custom object I have created records with name, start date and end date. 

I am looking to pre-populate the start date and end date of the OLI when a value is selected from the custom field with the values from the custom object's records already created.

I have started to create an Apex Class and a trigger, but I have never used Lightning component and I am not sure if it's even possible without a Visualforce Page?

Also, I would like to be able to hide the custom field from the OLI depending on the type of product selected.

It is possible to build this in Lightning Component?

Thanks a lot.
S
Hi,

I am in Lightning and I am currently using Salesforce's standard functionality of adding products on an opportunity.

As we have different types of products, when the users are selecting the products from the Add Products page and click the button Next, I want to be able to hide a Lookup field to a custom object I have created on the OLI - depending on the type of product selected. 

Also, when the Lookup field is showing on the OLI for some of the products, I want to prepoluate another two fields from the OLI with the values of the records from the Lookup field.

Is it possible to achieve this only by creating an Apex code? Without having to create a Visualforce page?


Thanks a lot.
Hi,

I am interested to know, please, if there is a way to associate a lead from the website to a Campaign in Salesforce, and to create the Campaign automatically as well, when pushing through the lead?

I know it is possible to associate a new web lead with a Campaign, and include the Campaign ID and the Campaign Member Status in the web-to-lead form and have the Lead associated to specific Campaigns, but the IDs will always have to be updated in the website code?


Thanks.
Hi,

I am trying to create a Visualforce Page to replace the Add Products pop up window.

I want the users to be able to select the Product Family from a drop-down list and based on the Product Family, when they search for products - only active products that belong to that Product Family to come up. The Product Family is a picklist field on the Product object.

I have started working on the picklist visualforce and Apex code, but I am not sure if I got any close as I don't have experience with Apex classes and Visualforce Pages.

Could you please help?

Please see below what I have tried so far:

VF:

<apex:page controller="ProductFamilly">
    <apex:form >
        <apex:pageBlock>
          <apex:pageBlockSection title="Select Product Type">
      </apex:pageBlockSection>  
         <apex:pageBlockSection title="ProductType">
             <apex:pageBlockTable value="{!Family}">
                 <apex:column value="{!family.values}"/>
             </apex:pageBlockTable>
             <!--apex:pageBlockButtons-->
                 <apex:commandButton value="FIND" action="{!pf}"/>
             <!--/apex:pageBlockButtons-->
         </apex:pageBlockSection>   
     </apex:pageBlock>       
    </apex:form>
</apex:page>


Apex Class:

public List<ProductFamily> ProductValues{get; set;}
Public Dynamicfiltercon(){
        ProductValues=<ProductFamily>([SELECT values, FROM ProductFamily]);
    }

I am still looking into the search functionality code.


Thanks.
Hi,

I am trying to Save an Apex Class. Please see below:

public class clsHelpSalesStages{
  
  public List<OpportunityStage> getSalesStages(){
    
    List<OpportunityStage> lstOppStage = [ SELECT MasterLabel, 
                           IsClosed,
                           IsWon, 
                           ForecastCategory, 
                           ForecastCategoryName, 
                           DefaultProbability, 
                           Description
                    FROM OpportunityStage
                    WHERE IsActive = true
                    ORDER BY SortOrder ASC ];
    return lstOppStage;
  }
  
  public static testMethod void testMyController(){ 
    clsHelpSalesStages objOppStage = new clsHelpSalesStages();
    List<OpportunityStage> lstOppStageTest = objOppStage .getSalesStages();
  
    System.assert( lstOppStageTest.size() > 0 );
  }
}

But I am getting the following error message: Error: Compile Error: Defining type for testMethod methods must be declared as IsTest at line 18 column 33

The Apex Class is used to show Opportunity Stages Description on the Home Page.

I can see that - The testMethod keyword is now deprecated, so therefore the error. 

I have tried to use @isTest, but it didn't work.

I've never created an Apex Class before, unfortunately, so I am unable to correct the error message.

Could you please let me know what should I correct?


Thanks.
Hi,

I am looking to customize the opportunity line item page and I was wondering what's the best solution to achieve this?

Depending on the product selected on the Add Products popup page, I want to be able to show different fields in the Edit Selected Products page based on the Product Family the product belongs to.

I did create a lookup field to the custom object from Opportunity Product, but it isn't ideal, as the custom object doesn't apply for all the products.

Do I need to create a visulaforce page to replace the "Next" button or what's the best solution? I am not very familiar with creating VF pages, unfortunately.

Thanks
Hi,

I am in Lightning and I am currently using Salesforce's standard functionality of adding products on an opportunity.

As we have different types of products, when the users are selecting the products from the Add Products page and click the button Next, I want to be able to hide a Lookup field to a custom object I have created on the OLI - depending on the type of product selected. 

Also, when the Lookup field is showing on the OLI for some of the products, I want to prepoluate another two fields from the OLI with the values of the records from the Lookup field.

Is it possible to achieve this only by creating an Apex code? Without having to create a Visualforce page?


Thanks a lot.
Hi All,

I have a Process Builder and a Validation Rule on the Opportunity Object.

The Validation Rule is meant to stop the users from modifying an Opportunity once Closed Won, apart from Admins.
 
AND
(ISPICKVAL(PRIORVALUE(StageName),"Closed Won"), CASE($Profile.Name, 
"ProfileName1",1, 
"ProfileName2",1, 
0)=0 
)

And the Process Builder is checking if "[Opportunity].IsClosed = TRUE, and updates the Close Date = TODAY().

Error message:
 
> The flow tried to update these records: null. This error occurred:
> FIELD_CUSTOM_VALIDATION_EXCEPTION


Both the Process Builder and the Validation Rule work fine, but activated separately.

Is there a way to stop the users from modifying the Closed Won Opportunity, but allow the process to change the Close Date for the users?


Thanks.
Hi All,

I hope you're all well.

I have a custom object - Object 1 and the Opportunity object. I've created a lookup field from the Opportunity to Object 1 and I want to be able to populate the id of a related record into the lookup field, in order to reference some of the values, back on the Opportunity.

The related records on the Object 1 are being created first (as part of an integration), so I want my trigger to fire after the records are created, or modified.

One Opportunity, could have 1+ related records.

In order to differentiate for each Opportunity, those records are related to, we have two custom fields, field 1 on the Opportunity that contains an unquie number and another custom field on the Object 1 that contains the same unquie number the Opp has.

I want my trigger to fire everytime the related records are created and populate the id of one of them into the lookup, so I can reference different values from the Object 1.

This is what I have attempted to build so far, but I am not having much success... so a little bit of help, it's much appreciated. 

I built the trigger on the custom object 1, but I am not sure if  this is correct...
 
ttrigger UpdateLookup on Object_1__c (after insert, after update){
for (Object_1__c obj: trigger.new){
    Obj1Ids.add(obj.id);
}

Map <Opportunity> matchingIdsMap = new Map <Opportunity> ();

for (Opportunity obj: [Select Id, field_1__c from Opportunity, where id in:ObjIds]){
matchingIdsMap.put(Opportunity.id, Opportunity);
}

List <Opportunity>OpportunitiesToUpdate = new List <Opportunity> ();

for (Object_1__c obj: trigger.new){

if (matchingIdsMap.get(obj.id) ! = null)



{

   matchingIdsMap.get(obj.id).Object_1__C = ObjIds;

   OpportunitiesToUpdate.add (matchingIdsMap.get(ObjIds));

}

update OpportunitiesToUpdate;
}

Thanks a lot.
 
Hi guys,

I am using Lightning and its standard functionality of adding products on an opportunity. I have created a custom field (let's call it X) on the Opportunity Product that it's a Lookup field to a custom object (not ideal)

On the custom object I have created records with name, start date and end date. 

I am looking to pre-populate the start date and end date of the OLI when a value is selected from the custom field with the values from the custom object's records already created.

I have started to create an Apex Class and a trigger, but I have never used Lightning component and I am not sure if it's even possible without a Visualforce Page?

Also, I would like to be able to hide the custom field from the OLI depending on the type of product selected.

It is possible to build this in Lightning Component?

Thanks a lot.
S
Hi,

I am trying to Save an Apex Class. Please see below:

public class clsHelpSalesStages{
  
  public List<OpportunityStage> getSalesStages(){
    
    List<OpportunityStage> lstOppStage = [ SELECT MasterLabel, 
                           IsClosed,
                           IsWon, 
                           ForecastCategory, 
                           ForecastCategoryName, 
                           DefaultProbability, 
                           Description
                    FROM OpportunityStage
                    WHERE IsActive = true
                    ORDER BY SortOrder ASC ];
    return lstOppStage;
  }
  
  public static testMethod void testMyController(){ 
    clsHelpSalesStages objOppStage = new clsHelpSalesStages();
    List<OpportunityStage> lstOppStageTest = objOppStage .getSalesStages();
  
    System.assert( lstOppStageTest.size() > 0 );
  }
}

But I am getting the following error message: Error: Compile Error: Defining type for testMethod methods must be declared as IsTest at line 18 column 33

The Apex Class is used to show Opportunity Stages Description on the Home Page.

I can see that - The testMethod keyword is now deprecated, so therefore the error. 

I have tried to use @isTest, but it didn't work.

I've never created an Apex Class before, unfortunately, so I am unable to correct the error message.

Could you please let me know what should I correct?


Thanks.
Hi,

I am looking to customize the opportunity line item page and I was wondering what's the best solution to achieve this?

Depending on the product selected on the Add Products popup page, I want to be able to show different fields in the Edit Selected Products page based on the Product Family the product belongs to.

I did create a lookup field to the custom object from Opportunity Product, but it isn't ideal, as the custom object doesn't apply for all the products.

Do I need to create a visulaforce page to replace the "Next" button or what's the best solution? I am not very familiar with creating VF pages, unfortunately.

Thanks