• Adam Pietraszek
  • NEWBIE
  • 20 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 8
    Replies
Having an issue with two lines of my code:
pbe.Reference__c = 'donkey'; -- I'm just trying to write a value to Reference which is a plain text box.

pbe.Franchise__c = prd.Franchise__c; -- I'm trying to set a picklist inside 'pbe' based on a picklist of the same name from 'prd'

Not sure why these aren't working. There are other fields that are referenced in my code and they seem to work but these two do not work. No compile errors and no runtime errors but it's like those lines are being skipped. Any ideas what I could be missing?

trigger ProductCreateEntries on Product2 (after insert) {

List<Pricebook2> pricebooks = [SELECT id,Name,Franchise__c FROM Pricebook2 WHERE IsStandard = false];
Pricebook2 standardPricebook = [SELECT id,Name,Franchise__c FROM Pricebook2 WHERE IsStandard = true LIMIT 1];
List<PricebookEntry> newEntries = new List<PricebookEntry>();
List<PricebookEntry> standardEntries = new List<PricebookEntry>();
    for (Product2 prd : Trigger.new) {
        if (prd.Franchise__c == 'ENT') {
        //create standard pricebook entries
        PricebookEntry stdPbe = new PricebookEntry();
        stdpbe.Product2Id = prd.Id;
        stdpbe.Pricebook2Id = standardPricebook.Id;
        stdpbe.IsActive = true;
        stdpbe.UseStandardPrice = false;               
        if(prd.Standard_Price__c != null) {
            stdpbe.UnitPrice = prd.Standard_Price__c;
        }
        else {
            stdpbe.UnitPrice = 0;
        }     
        standardEntries.add(stdpbe);
        //create entries for all non-standard pricebooks   
        for(Pricebook2 pb : pricebooks) {
            if (prd.IsActive == true) {
                PricebookEntry pbe = new PricebookEntry();
                pbe.Product2Id = prd.Id;
                pbe.Pricebook2Id = pb.Id;
                pbe.IsActive = true;
                pbe.UseStandardPrice = true;
                pbe.Reference__c = 'donkey';
                pbe.Franchise__c = prd.Franchise__c;
                if(prd.Standard_Price__c != null) {
                pbe.UnitPrice = prd.Standard_Price__c;
                }
                else {
                    pbe.UnitPrice = 0;
                }
                newEntries.add(pbe);
            }
        }   
    }
    upsert standardEntries;    
    upsert newEntries;
    }
}
I've taken over our org from the previous dev and even though I'm not a developer (I'm the admin) I need to fix this issue. I have limited dev experience but I figured I'll give this a shot.
We are using lightning components for our opportunities. We also have a few custom fields on the page layout as well in addition to the lightning component. 
The lightning component has a custom button that changes the stages of the opportunity. 
I would like to add a line of code to that button that will also change the value of one of the custom picklists. This picklist does not exist in the lightning component - it's just a custom field on the layout itself. 
The button click action is on the ComponentHelper.js so I'm adding the line there but I'm having issues.
The custom field is Demo_Audit_Status__c so I thought the line of code would be:
component.set("Demo_Audit_Status__c", "No Demo Needed");
I'm pretty sure I'm oversimplifying what I need but I'd rather fix this before having to reach out to the original devs.
I'm trying to write a simple Apex trigger (which I've piecemealed from the internet) and it keeps returning my own info instead of what I'm actually querying for.

I have a custom object where I will import ~3000 rows of data using data loader. One of the fields being imported is "Territory Manager." Based on that field, which is a lookup field, I need to auto-populate a second field called "Regional Manager" - also a lookup field.

The code I have now keeps populating the "Regional" field with MY manager instead of the "Territory Manager's" manager.

I am very new to Apex so it'll probably be something obvious to you but if you could help me out I'd appreciate it.
 
trigger getRSMofTM on Equipment_Performance__c (before insert) 
{
    for (Equipment_Performance__c area : trigger.new) 
    {
        if(area.Territory_Manager__c != null)
        {
            Id mgrid = [select id, managerid from user where id =: userinfo.getUserId()][0].managerid;
            string managername = [select id, name from user where id =: mgrid][0].name;
            system.debug('=================' + managername);
            area.Regional_Manager__c = mgrid;
        }
    }
}

 
I'm having a hell of a time with this issue. I'm the Salesforce Admin and my dev skills are limited to front-end web dev. I inherited an org with quite a bit of code on it and I was asked to make a change to our Oppotunity.

Right now if you want to close an Opp, a Lightning Component pops up and asks you 3 questions (picklists) and 1 multi-line text box.

The Save button is disabled until you select all the dropdowns. However, management wants people to start filling in the comments so I'm trying to keep the Save button disabled until the comment box is filled out as well.

Here's the code of the lightning component for the comment box:
<lightning:textarea aura:id="closeCommentsInput" label="Close Comments" value="{!v.opp.Close_Comments__c}" required="true" minlength="1" maxlength="30000"/>
And here's the code fot he controller:
if( (component.get("v.opp.StageName") === 'Closed Won' && component.get("v.opp.Primary_Driver_for_Win__c") != '') || (component.get("v.opp.StageName") === 'Closed Lost' && component.get("v.opp.Lost_To__c") != '' && component.get("v.opp.Primary_Driver_for_Loss__c") != '') {
	component.find("saveButton").set("v.disabled","false");
	}
	else {
		component.find("saveButton").set("v.disabled","true");
		}

And here's the controller code w/ the changes I've attempted that I thought would work. Please understand that my Salesforce coding is novice at best. If I could use something like jQuery I'd have this done in a minute but i'm stumped and I'm sure I'm overlooking something major:
if( (component.get("v.opp.StageName") === 'Closed Won' && component.get("v.opp.Primary_Driver_for_Win__c") != '') && component.get("v.opp.Close_Comments__c") != '') || (component.get("v.opp.StageName") === Closed Lost' && component.get("v.opp.Lost_To__c") != '' && component.get("v.opp.Primary_Driver_for_Loss__c") != '' && component.get("v.opp.Close_Comments__c") != '') {
	component.find("saveButton").set("v.disabled","false");
	}
	else {
		component.find("saveButton").set("v.disabled","true");
		}
I've read through a lot of the Lightning Components Dev Guide but I'm lost at this point and hoping someone could point me in the right direction.

Thank you all.
 
I've taken over our org from the previous dev and even though I'm not a developer (I'm the admin) I need to fix this issue. I have limited dev experience but I figured I'll give this a shot.
We are using lightning components for our opportunities. We also have a few custom fields on the page layout as well in addition to the lightning component. 
The lightning component has a custom button that changes the stages of the opportunity. 
I would like to add a line of code to that button that will also change the value of one of the custom picklists. This picklist does not exist in the lightning component - it's just a custom field on the layout itself. 
The button click action is on the ComponentHelper.js so I'm adding the line there but I'm having issues.
The custom field is Demo_Audit_Status__c so I thought the line of code would be:
component.set("Demo_Audit_Status__c", "No Demo Needed");
I'm pretty sure I'm oversimplifying what I need but I'd rather fix this before having to reach out to the original devs.
I'm trying to write a simple Apex trigger (which I've piecemealed from the internet) and it keeps returning my own info instead of what I'm actually querying for.

I have a custom object where I will import ~3000 rows of data using data loader. One of the fields being imported is "Territory Manager." Based on that field, which is a lookup field, I need to auto-populate a second field called "Regional Manager" - also a lookup field.

The code I have now keeps populating the "Regional" field with MY manager instead of the "Territory Manager's" manager.

I am very new to Apex so it'll probably be something obvious to you but if you could help me out I'd appreciate it.
 
trigger getRSMofTM on Equipment_Performance__c (before insert) 
{
    for (Equipment_Performance__c area : trigger.new) 
    {
        if(area.Territory_Manager__c != null)
        {
            Id mgrid = [select id, managerid from user where id =: userinfo.getUserId()][0].managerid;
            string managername = [select id, name from user where id =: mgrid][0].name;
            system.debug('=================' + managername);
            area.Regional_Manager__c = mgrid;
        }
    }
}

 
I'm having a hell of a time with this issue. I'm the Salesforce Admin and my dev skills are limited to front-end web dev. I inherited an org with quite a bit of code on it and I was asked to make a change to our Oppotunity.

Right now if you want to close an Opp, a Lightning Component pops up and asks you 3 questions (picklists) and 1 multi-line text box.

The Save button is disabled until you select all the dropdowns. However, management wants people to start filling in the comments so I'm trying to keep the Save button disabled until the comment box is filled out as well.

Here's the code of the lightning component for the comment box:
<lightning:textarea aura:id="closeCommentsInput" label="Close Comments" value="{!v.opp.Close_Comments__c}" required="true" minlength="1" maxlength="30000"/>
And here's the code fot he controller:
if( (component.get("v.opp.StageName") === 'Closed Won' && component.get("v.opp.Primary_Driver_for_Win__c") != '') || (component.get("v.opp.StageName") === 'Closed Lost' && component.get("v.opp.Lost_To__c") != '' && component.get("v.opp.Primary_Driver_for_Loss__c") != '') {
	component.find("saveButton").set("v.disabled","false");
	}
	else {
		component.find("saveButton").set("v.disabled","true");
		}

And here's the controller code w/ the changes I've attempted that I thought would work. Please understand that my Salesforce coding is novice at best. If I could use something like jQuery I'd have this done in a minute but i'm stumped and I'm sure I'm overlooking something major:
if( (component.get("v.opp.StageName") === 'Closed Won' && component.get("v.opp.Primary_Driver_for_Win__c") != '') && component.get("v.opp.Close_Comments__c") != '') || (component.get("v.opp.StageName") === Closed Lost' && component.get("v.opp.Lost_To__c") != '' && component.get("v.opp.Primary_Driver_for_Loss__c") != '' && component.get("v.opp.Close_Comments__c") != '') {
	component.find("saveButton").set("v.disabled","false");
	}
	else {
		component.find("saveButton").set("v.disabled","true");
		}
I've read through a lot of the Lightning Components Dev Guide but I'm lost at this point and hoping someone could point me in the right direction.

Thank you all.