Hot answers tagged

63

[comic but unsupported - don't do this] This can be pulled off, but you need to get crafty :-) here's one I prepared with pink candy polka dots: go to Setup > Create > Objects > [Your Object] > Custom Buttons and Links, and hit New, create a Detail Page Button whose behaviour is to Execute JavaScript, modify the following JavaScript, using your lowercased ...


25

The right syntax to do this is below var btn = event.getSource(); btn.set("v.disabled",true);//Disable the button


20

This came out in Winter16. It's part of the approval class Approval.isLocked(recordId) This method can also accept List<Id>, SObject, or List<SObject>. You can also now lock and unlock them from Apex. See the documentation on the Approval class.


17

You need to use the AJAX Toolkit. Set the detail button to execute a bit of javascript on click. eg {!requireScript("/soap/ajax/26.0/connection.js")} var account = new sforce.SObject("Account"); account.id = //set Record Id here, potentially get it from the URL ?id= param account.field__c = value; sforce.connection.update([account]); window.location....


12

I like Sdry's answer a lot, but there were two issues with it that I wanted to address: I don't want to include jQuery in a home page component. It doesn't work when the script runs before the element you are trying to hide is added to the dom. It really needs to be ran onDomReady. So, after a bit of tinkering and finding out about Sfdc.onReady I came up ...


10

We use homepage components which analyse the page, and use javascript to remove/add buttons where we have no other choice to do so. But this implies developing with a high dependency on the salesforce html output .. which is not guaranteed to stay unchanged, this is something to strongly consider if you would explore this approach. Why do you want to ...


8

Do you want to to override the standard 'Save' button for this? You can simply write a 'before insert, before update' trigger that will do all field setting you need before saving the record into the database


8

First, make your trigger into a static webservice function: global class OpportunityWS { webservice static void createAsset(Id opportunityId) { // Do logic here } } Then, create a custom JS button or link on the opportunity: {!RequireScript("/soap/ajax/34.0/connection.js")} {!RequireScript("/soap/ajax/34.0/apex.js")} function success() { //...


7

Just for clarification, the reason that this is happening in your page is not that it doesn't execute 'fast enough' but instead the intended behaviors are occurring in the wrong order. The manner in which I normally accomplish this behavior is like this... a button on the page calls a function (of my own) which first calls the actionFunction to post the ...


7

There is a small article on Salesforce help You have access to the Sharing button when your sharing model is either Private or Public Read Only for a type of record or related record. For example, the Sharing button may appear on an account even though your organization-wide default for accounts is Public Read/Write, if your organization-wide default for ...


7

Please refer to this: https://help.salesforce.com/articleView?id=actions_in_lex.htm&type=0 In Lightning Experience, actions display in the Global Actions menu in the header, on related lists, on list view items, and in several places on a record page. Where they appear on a record page depends on the action’s type. [...] The page-level action menu in ...


6

I think there are three general approaches you can take here: (Preferred) Use the $Profile global variable, in conjunction with detecting the Record Type either from URL Parameters or from the object' RecordType.Name field, in a giant case statement. For instance, the following page could be used to override the Account object's New action, assuming that ...


6

This is how I solved this issue: public Boolean doesOpportunityHavePendingApproval() { return ![ Select Id From ProcessInstance WHERE TargetObjectId =: theOpportunity.Id AND Status = 'Pending' ].isEmpty(); }


6

The IsLocked field is not currently exposed via the API or SOQL, but there's an idea on the IdeaExchange to add that functionality. In the meantime, you can work around that by created a custom field on the object called In_Approval_Process__c, and edit your approval process to set this field when the record is submitted for approval and clear it after ...


6

I believe it's possible to query for the existence of an Approval Request related to your record, I believe this is via: ProcessInstance. Try checking out: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_process_example.htm Additionally, you could write a method to attempt to update the record, and trap the exception message ...


6

You said you want to send it to "fixed email address" You don't need "To" field. "To" will correspond to "recipient" record (Contact/Lead/User) which can be referred to in the email template. For just a hardcoded mailbox use "Additional To" instead: &p24=example@example.com If you want to populate the "To" after all p2 is the visible name field, "John ...


6

The v. prefix is used to access aura:attribute values. To invoke a controller method you need to use the c. prefix i.e.: onclick="{!c.clickHandle}" See e.g. Trailhead's Handle Actions with Controllers. I don't know why the button is silently failing for you. For me I got an error dialog that hinted at the problem: Access Check Failed! AttributeSet.get()...


5

One sort of clunky workaround is to override the "New" function on the Opportunity object to redirect to a page that simply says, "Please create Opportunities from the Account Page" or something like that. This is probably the simplest way to keep them from using the standard New button, and just using your custom button on the Account Page.


5

Check what does this return for you: var value = '{!Opportunity.Amount}'; var blankTest = {!ISBLANK(Opportunity.Amount)}; alert (value + "\r\n" + typeof blankTest + ' ' + blankTest); (note that you had syntax error, ISBLANK should be within the {!...}) RE: "Unexpected token !" No, you can't have code like { ! ... and expect it to work! Maybe you did ...


5

Try this app - just came up on a call today! I believe this would allow what you are asking to do. https://appexchange.salesforce.com/listingDetail?listingId=a0N3000000B4AJKEA3


5

If the Account name includes a single quote the JavaScript would then be invalid because that single quote would be interpreted as a string delimiter. Using {!JSENCODE(Account.Name)} would protect against that as described in the JSENCODE documentation: Encodes text and merge field values for use in JavaScript by inserting escape characters, such as a ...


5

You can query for created date for both records and whichever has later date that is cloned.


5

Recommended reading: Difference between controller and extensions Here you are working on writing a Controller Extension. You add this Apex Class to your page via the extensions attribute on the <apex:page> tag. If you want to enable a Detail Button on Account, your Visualforce Page must use the standardController attribute. <apex:page ...


5

You should be able to use the SLDS Float classes: <div id="hidden"> <div class="slds-float--right"> <!--Add Folder Button--> <button class="slds-button slds-button--icon folder" onclick="{!c.modalFolOpen}" aria-live="assertive"> <c:svg ariaHidden="true" class="slds-icon--small slds-button__icon" ...


5

It is created via following css class: .forceListViewManagerHeader .rotate svg { animation: rotate .4s; } Check the screenshot also


5

setAttribute is for setting HTML attributes. For component attributes, use direct assignment: event.target.iconName='utility:check" If you use query selectors, just remember that if it's not an HTML component, use the direct assignment method.


4

There is no way to declaratively modify the color of a standard button that is part of Salesforce configuration. See this other post on some crafty ways to modify the Salesforce CSS. Can I apply a custom stylesheet to modify the look and feel of a standard object detail page?


4

Salesforce already disables the buttons on standard page layouts when a Save is selected. I took a look at their main.js javascript file, and it looks like the following function is what is called when a Save is clicked: DetailPage.prototype.save = function () { if (!this.saving && this.editMode) { this.saving = !0; for (var a = ...


4

You are mixing your drinks! Looks like you want client-evaluated code in server-evaluated functions ;-) Try this: window.parent.location.href="{!URLFOR($Action.Event.NewEvent, null, [ who_id=pba__Request__c.Id, what_id=pba__Request__c.Id, retURL=URLFOR($Action.pba__Request__c.View, pba__Request__c.Id), evt3=pba__Request__c.Name, evt5="...


4

It very much depends on whether the author of the managed package intended the method to be called in this manner. If the page controller exposes the action behind the button globally, there may be a good chance that you can. Of course, there maybe other variables on the page and/or controller itself that might be required to make that method call successful....


Only top voted, non community-wiki answers of a minimum length are eligible