+ Start a Discussion
Connor ScottConnor Scott 
Howdy all,
My company is looking for a good way to keep track of which companies are subscribed to different products, especially with little data entry. Would any of you have any suggestions, how your company handles this, anything pre-built in to salesforce we should be using, that sort of thing. It would be very nice to go to a companies record and see which services and products they are currently using. Any and all input would be greatly appreciated!
Best Answer chosen by Connor Scott
Magulan DMagulan D
Asset object is the best place to have these information.
--
Magulan Duraipandian
www.infallibletechie.com
Stéphane C.Stéphane C. 
Hi,

I want to prevent a non administrator user to delete closed won opportunities.

I think a trigger can be a good solution.
 
trigger ClosedWonOpportunityTrigger on Opportunity (before delete) {
    for(Opportunity o: Trigger.Old)
        if($Profile.Name <> "System Administrator" && o.stagename=='Closed Won’)
        	o.addError(‘You cannot delete a Closed Won Opportunity. Please contact the Accounting Department. Thank you.’);
}

Do you think this apex can work?

Thank you.
Best Answer chosen by Stéphane C.
Manohar kumarManohar kumar

Hi Stephane,

pls try some like this

 

trigger ClosedWonOpportunityTrigger on Opportunity (before delete) {
    for(Opportunity o: Trigger.Old) {
      id id1 = userinfo.getProfileId();

string profileName = [select Name from profile where id = :id1].name;
        if(profileName == "System Administrator" && o.stagename=='Closed Won’)
        	o.addError(‘You cannot delete a Closed Won Opportunity. Please contact the Accounting Department. Thank you.’);

}
}
ccazzccazz 
I am trying to do the following:
Call Apex from a Process or Flow (Invocable Method),
Make an HTTP Callout (can't do this from invocable method so using a queueable class)

I have been using these examples to write the code related to invocable variables:
1. https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_InvocableVariable.htm
2. https://developer.salesforce.com/forums/?id=9060G0000005nusQAA

Here is what I have:
public class EnqueueCallout {

    @InvocableMethod(label='Enroll in XYZ Program' )
    public static void queueCallout(List<FlowInputs> calloutvars) {
        string card = calloutvars.cardnum;
        string offer = calloutvars.offerid;
//this calls the queueable class and sends the variables...this part works fine when using the execute command in the execute anonymous apex window.
        ID jobID = System.enqueueJob(new SendCallout(card, offer));
    }
    //input details that come into apex from flow
    public class FlowInputs {
        @InvocableVariable(required=true)
        public string cardnum;
        
        @InvocableVariable(required=true)
        public string offerid;
    }
}

but I am getting the error "Error: Compile Error: Variable does not exist: cardnum at line 5 column 35"
Best Answer chosen by ccazz
AmarpreetAmarpreet
Hi,

Use this:
string card = calloutvars[0].cardnum;
string offer = calloutvars[0].offerid;

OR, iterate "calloutvars" in for each loop.
for(FlowInputs fi: calloutvars){
            string card = fi.cardnum;
            string offer = fi.offerid;
        }
Zen Newman 1Zen Newman 1 
Hello, fairly new to Visualforce. I'm trying to create a Visualforce page to replace the default create new opportunity page. The code I used came from a similar new account page which is working. I'm seeing no warrnings in the developer console and the page displays fine, but when I click the save button, no record is created and when I click the cancel button, it flags required fields as needing to be filled out to move forward. Can someone tell me where I'm going wrong? Thank you! 
 
<apex:page standardController="Opportunity" lightningStylesheets="TRUE" showHeader="TRUE" docType="html-5.0">
    <apex:SectionHeader title="New Opportunity"> 
    	<apex:form >
        	<apex:pageBlock title="Add Opportunity"  mode="edit">
          		<apex:pageBlockButtons >
            		<apex:commandButton action="{!save}" value="Save"/>
            		<apex:commandButton action="{!cancel}" value="Cancel" immediate="true"/>
       			</apex:pageBlockButtons> 
                <apex:pageBlockSection >
                    <apex:inputField value="{!Opportunity.Name}" />
                    <apex:inputField value="{!Opportunity.AccountId}" />
                    <apex:inputField value="{!Opportunity.Stagename}" /> 
                    <apex:inputField type="date" showDatePicker="TRUE" value="{!Opportunity.CloseDate}" required="TRUE" /> 
                    <apex:inputField type="date" showDatePicker="TRUE" value="{!Opportunity.Project_Launch_Date__c}" required="TRUE" /> 
                    <apex:inputField value="{!Opportunity.Broker_Account__c}" />
                    <apex:inputField value="{!Opportunity.Broker_Contact__c}" /> 
                </apex:pageBlockSection>
            </apex:pageBlock>
    	</apex:form>
    </apex:SectionHeader>
</apex:page>

Screenshot
Best Answer chosen by Zen Newman 1
AmarpreetAmarpreet
Hi,

Please try below Code:
 
<apex:page standardController="Opportunity" lightningStylesheets="TRUE" showHeader="TRUE" docType="html-5.0">
    <apex:SectionHeader title="New Opportunity"> 
    	<apex:form >
        	<apex:pageBlock title="Add Opportunity"  mode="edit">
          		<apex:pageBlockButtons >
            		<apex:commandButton action="{!save}" value="Save"/>
            		<apex:commandButton action="{!cancel}" value="Cancel" immediate="true"/>
       			</apex:pageBlockButtons> 
                <apex:pageBlockSection >
                    <apex:inputField value="{!Opportunity.Name}" />
                    <apex:inputField value="{!Opportunity.AccountId}" />
                    <apex:inputField value="{!Opportunity.Stagename}" /> 
                    <apex:inputField  showDatePicker="TRUE" value="{!Opportunity.CloseDate}" required="TRUE" /> 
                    <apex:inputField showDatePicker="TRUE" value="{!Opportunity.Project_Launch_Date__c}" required="TRUE" />
                    <apex:inputField value="{!Opportunity.Broker_Account__c}" />
                    <apex:inputField value="{!Opportunity.Broker_Contact__c}" />

                </apex:pageBlockSection>
            </apex:pageBlock>
    	</apex:form>
    </apex:SectionHeader>
</apex:page>

 
LinThawLinThaw 
Hi,

I got following error on step 3.

Challenge Not yet complete... here's what's wrong: 
Couldn’t find Agency records from the Account object.

Can anyone pass this step?
Thanks in advance.

Regards,
LinThaw
Best Answer chosen by LinThaw
LinThawLinThaw
Hi Jennifer and ankita,

Please refer below, I passed this step 3.

fig 1.
User-added image

fig 2.
User-added image


and create Top 5 Agencies lenses.

Regards,
LinThaw
dpawndpawn 

I need to export a report as a CSV to an FTP site or email it on a daily or weekly basis.

 

I have a Report.  I need to get the report out of Salesforce somehow into CSV format.

 

Ideally, this would be scheduled.


I'm a developer so I can do developer stuff.  However, I don't know APEX and I don't know VisualForce.  I can get someone to do that stuff if we need to.


Thanks!

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox
global class Exporter implements System.Schedulable {
    global void execute(SchedulableContext sc) {
        ApexPages.PageReference report = new ApexPages.PageReference('/00O500000000000?csv=1');
        Messaging.EmailFileAttachment attachment = new Messaging.EmailFileAttachment();
        attachment.setFileName('report.csv');
        attachment.setBody(report.getContent());
        attachment.setContentType('text/csv');
        Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
        message.setFileAttachments(new Messaging.EmailFileAttachment[] { attachment } );
        message.setSubject('Report');
        message.setPlainTextBody('The report is attached.');
        message.setToAddresses( new String[] { 'asdf@asdf.com' } );
        Messaging.sendEmail( new Messaging.SingleEmailMessage[] { message } );
        
    }
}

Here's an example schedulable class that might be used to email a file. Note that the last five lines need to be ignored or stripped; I'll leave this as an exercise to the reader.

 

You could also build a SOQL query, execute it, then build the CSV yourself, but that means the system is hard-coded and less flexible. Of course, you could build an interactive configuration (perhaps by the use of a custom object or custom settings), which would help work around that particular limitation of flexibility, but that is by far more complex.

SandrineSandrine 
Hello,

I want to execute a processbuilder when a button is clicked, 
my custom button is like below
User-added image

thanks you for suggestion
Best Answer chosen by Sandrine
RamakantRamakant
Create a new number field. (I named mine Process Builder Trigger) Name it and remember to give it a description so later admins/devs do not get confused. You can put your condition as well.
Use below code in your button.
//I am assuming this code allows for the JS SOQL calls
//Check the resources section for SF documentation
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}
//Select the current account records and put it into the record //variable
var records = sforce.connection.query("SELECT Id, Process_Builder_Trigger__c FROM Account Where id = '{!Account.Id}'");
//The records object come with other garbage so we need to only pull //out the account we are working with
//Pull the account object out of the records variable and set it to //accountRec
var accountRec = records.getArray('records')[0];
//Increase accountRec Process_Builder_Trigger__c 
//JS sees the number field as a string so this will make sure that //is a number - Number(accountRec.Process_Builder_Trigger__c)
accountRec.Process_Builder_Trigger__c = Number(accountRec.Process_Builder_Trigger__c) + 1;
//Update accountRec object 
sforce.connection.update([accountRec]);
//Reload the page 
window.location.reload();

Add the button to the object layout.
Last create a process builder that fires when the number field is changed. Now the process builder can do whatever you want!

Please mark as a best answer if helped.
Juan Jose VelascoJuan Jose Velasco 
Hi, 
I'm following the "Optimize Sales Processes Using Path" unit, and when I'm going to create the event, I find out that the event tab is missing.
Event tab missing
Should I enable or activate it somehow? maybe by following another unit?


Any hint or help will be great.

Thank you very much in advance.
 
Best Answer chosen by Juan Jose Velasco
SandhyaSandhya (Salesforce Developers) 
Hi,


View the page layout for the Lead you want to update.
Make sure buttons for New Task, New Event, Log a Call, and Send an Email (not Send Email) are added to the Salesforce Mobile and Lightning Experience Actions section of the page layout.
Make sure your users have permission to create new tasks and events, log calls, and send email.

Also refer below help article.
https://help.salesforce.com/articleView?id=activitytimeline_configure_call_task_event_tabs.htm&type=5

Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
 
Best Regards
Sandhya
 
Peter Davids 4Peter Davids 4 

 
Hi all,

We need to implement the following pattern at my org:
  • callout to external data source
  • if that callout takes too long (according to some configurable threshold), log an error (ie do some DML)
  • if that callout timed out on the remote server, try it again
Recognizing the potential for the dreaded "You have uncommitted work pending. Please commit or rollback before calling out." error, I put the error logging code in a future method, thus isolating the DML from the callouts. However, the error is still being thrown. I reduced the issue down to this pattern:
public static void foo() {
    Http http = new Http();
    HttpRequest req = new Httprequest();
    req.setEndpoint('https://test.salesforce.com'); //whatever endpoint
    req.setMethod('GET');
    http.send(req); //works fine
    bar();
    http.send(req); //throws calloutexception
}

@future public static void bar() {

}
Am I correct to assume that calling a future method counts as a DML operation? Is there any documentation I'm missing somewhere?

 
Best Answer chosen by Peter Davids 4
Peter Davids 4Peter Davids 4
Martin FreireMartin Freire 
I've been working on this superbadge, near the end I got to this part:

Ada also tells you that the SolarBot Status Averages report needs some tweaks. First, the Support team wants to see trends over time, so they want the report to show data by week instead of by day. Second, they want a graph for this report called Weekly Panel Temperature and kWh that shows average panel temperature and average kilowatt hours as lines over time. Third, they want to see this graph on each SolarBot record page. Create the page and call it SolarBot Status Page With Chart. Include only information about the individual SolarBot in the chart.


What kind of page should I go for? I created a Lightning Record Page, a page layout, and it is not detecting any kind of page
Thanks in advance
Best Answer chosen by Martin Freire
Bedotroyee SarkarBedotroyee Sarkar
Please create a new Lightning Record Page named "SolarBot Status Page With Chart" and activate the page. Then try to add Report chart from standard elements (which you will find on the left panel of the page).

Please make sure on right side you are entering the label name for the chart, selecting the report "SolarBot Status Averages" and adding filter SolarBotID so that chart displays the record details only based on context.
If you do not select anything, it will set to the default one (The pie chart one).

Just adding report chart to the page layout not working for this challenge.