Hot answers tagged

12

Something like this what you're looking for? {!URLFOR('/apex/' + $CurrentPage.Name, null, ['id'=id])} It will compile into URLFOR alright, and resolve to an absolute URL including namespace: https://namespace.na14.visual.force.com/apex/Relative?id=000000000000000AAA I'm passing the id as second param, but it was being ignored, so I added it to the ...


9

See $Resource. To use $Resource in JavaScript, you have to actually call a method. Here's an example from the docs: ({ profileUrl: function(component) { var profUrl = $A.get('$Resource.SLDSv2') + '/assets/images/avatar1.jpg'; alert("Profile URL: " + profUrl); } }) When using URLFOR in component markup, you can use it directly, as ...


5

You can do this the naughty way (least code) using just the Id: <apex:outputLink value="/{!selectedId}" //pseudocode example rendered="{!IF(selectedId != null, true, false)}" /> or the nice, robust way (bleeds complexity into Apex) by using a controller: <apex:outputLink value="{!View}" //pseudocode example rendered="{!IF(...


4

You can't directly use JS in merge fields. URLFOR is built (merged) on the server, while JavaScript only makes sense in the context of a client. Instead, you have to use JavaScript to modify the URL afterwards: var url = '{!URLFOR($Action[objectname].New, null, mode='autocomplete',suggestValue='{value}'])}'.replace('{value}',queryTerm);


4

If you simply navigate to Setup > Custom Settings, and then copy the Manage link, it will look like below: https://some-domain.my.salesforce.com/setup/ui/listCustomSettingsData.apexp?id=a02 So it should be fairly easy to generate programatically in Apex. String relativePath = '/setup/ui/listCustomSettingsData.apexp'; String queryString = '?id=' + ...


3

Your parameter is incorrect and to answer your question of URLFOR Explained: <apex:outputLink value="{!URLFOR($Action.Admin_Tracking__c.New, null, [RecordType='012230000004LDD', save=1])}" target="_blank">Advanced Entry</apex:outputLink> http://salesforcesource.blogspot.com/2008/12/urlfor-function-finally-explained.html {!URLFOR(target, id, [...


3

The reason for the error is the parameter where you pass your id is null. So to avoid this error, hide the outputLink completely when the id of the attachment is null <apex:outputLink value="{!URLFOR($Action.Attachment.Download, item.AttachmentID)}" target="_blank" rendered="{!NOT(ISBLANK(item) && NOT(ISBLANK(item.AttachmentID))}">{!item....


3

I believe the params here are not the API names of the CustomFields, but the names of the HTML fields on the edit page. If I'm right, the parameters here are simply the query parameters of the URL. In order to do this sort of thing, you need to find two things: the CustomField Id (which usually starts with 00N, so let's pretend it's 00N111222333444555) and ...


3

I tried to replicate the issue today by extracting the same records from Production and reinserting them into my Sandbox. I was unsuccessful in causing the error. This further made me think the issue was with bad data in the record. I reviewed all fields on the record and discovered somehow I was able to import Production Ids into the Sandbox where the Id ...


3

Option 1 Seems like it may have to do with Knowledge Article Number: 000170866. Knowledge Article Number: 000170866 Description Including visualforce pages in page layouts causes the page to not load and receives error: URL No Longer Exist. The URL that the error refers to is the servlet/servlet.integration trying to load the visualforce page. ...


3

Since you're already "escaped", you don't need to escape again. Assuming the variable is called cssName: @import url({!URLFOR($Resource.brand, cssName)});


3

The URLFOR is a Visualforce tag that is rendered ONCE the page is loaded/re-rendered (the value of the tag is resolved on the server). It allows only plain text values or apex variables. So you CAN'T pass javascript variables in it. What you can do it to reference your visualforce page using URLFOR and add parameters separately to the string: var pageUrl = ...


3

What you are trying to do is referred to as URL hacking, which is not supported by Salesforce. You are correct that your solution could break should Salesforce make any backend changes. I would propose that rather than trying to use URLFOR() to account for this, you look into using Publisher Actions. Publisher actions all but make URL hacking a thing of ...


2

Since you are already using a VF page for helping the approval submission why not create an method with return type of pagereference in your AgreementApprovalRedirect extension and use it to redirect to the desired page? The code would look something like this: Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest(); req1.setComments('...


2

On a Force.com Site, the implementation of URLFOR() and Page.Master.getUrl() differ: URLFOR() returns an all-lowercase string without /apex prefix. PageReference.getUrl returns a first-letter-capitalized string with /apex prefix. public class UrlForController { public String getApexUrl() { return Page.MaStEr.getUrl(); } } <apex:page ...


2

The change screen does not set the value, it simply get the selected value and passes it as a URL parameter. If you controller is updating the record and not grabbing the selected record type from the URL parameter then the new record type will never be applied to the record


2

You need to override the override. Pass "true" for the optional fourth parameter: <apex:page standardController="Consumable_Analysis__c" extensions="AnalysisClonerHelper" action="{!IF(pcs,null,URLFOR($Action.Consumable_Analysis__c.Clone,Id,[retURL=Id],true))}" >


2

Your link variable should look like this. var link = '{!URLFOR($Page.ActivityPage,null)}'+'?activityId='+actid+'&contactId='+contid;


2

In addition to @Sfdcfox, you can simply use following solution var url = 'URLFOR($Action[objectname].New, null),'')}' + '?mode=autocomplete&suggestValue=' + queryTerm;


2

I focused on getting the Cancel action from new Sobject page to return to a page other than from whence I started. Apologies for not using Cases Foo__c has record types a09/e is the key prefix for Foo__c ID is the ID of the record of the VF page where the outputLink exists - I used a standardController to test this; you could use something different here ...


2

Do not put a merge field inside a merge field. As you have it now, you have this: {! ... {! ... } ... } This will confuse the compiler and result in the last error you received. You also shouldn't need URLENCODE-- everything inside of [] is taken care of for you automatically. As near as I can tell, this should work: window.parent.open( "{!URLFOR( ...


2

Managing Custom Settings in Lightning are always a challenge in my view. I would suggest taking a look at what Salesforce.org does here in the NPSP Package: Basically, they created a wrapper VF page that then lets you navigate to each setting that lives in its own included VF page, and you can then edit/update with a simple shared controller. Yes, it is ...


2

You can do like this:- /lightning/o/Case/new?defaultFieldValues=RecordTypeId=012B0000000RBwHIAW, AccountId={!Account.Id}&backgroundContext=%2Flightning%2Fr%2FAccount%2F{!Account.Id}%2Fview


1

Although it is not clear on what you are exactly looking for. At first glance, looks like you have problem with syntax. You can use following syntax to concatenate parameters inside merge field: var iframe_url = '{!URLFOR("/apex/MemberVerification?memberReferral=" + URLENCODE(Contact.Active_Member_ReferralId__c))}'; Note: URLENCODE is helpful and ...


1

The easiest way, if you know what object types you're dealing with, would be to hardcode a map. var nameToPrefixLookUp = { 'Account' : '001', 'Contact' : '003'..} //then in your code window.location = '/' + nameToPrefixLookUp[sobjectType]; This is going to fall short if you won't know the full list of objects, or if you're using custom objects and ...


1

This is well-covered in the Visualforce in Practice documentation, an often overlooked VF resource. See section "Stateless Actions" in Chapter 2 for a good explanation with many examples. The documentation takes the mystery out of the $Action.xx global variables and tells you what to use for the second URLFOR argument when the id is null. You'll also see ...


1

Here it is! https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_variables_functions.htm Returns a relative URL for an action, s-control, Visualforce page, or a file in a static resource archive in a Visualforce page. This can be used to return a reference to a file contained in a static resource archive (such as a .zip or .jar file). {...


1

URLFOR is normally used in an apex:outputLink; an apex:commandButton is normally bound to a controller method: <apex:commandButton ... action="{!saveAndAssign}"/> If your aim is to first invoke the saveAndAssign controller method and then go to the Account view page, then the other change to make is to return the new page reference from that method: ...


1

This is the default behavior of the Mobile Cards, where the Mobile Card simply shows a preview of the Visualforce page. Once clicked, you are redirected to the full Visualforce page.


1

I've set up a similar environment and it seems to work for me with the first 15 characters of KnowledgeArticleId. This is the controller method: public List<KnowledgeArticleVersion> getSearchResults(){ List<KnowledgeArticleVersion> articleList= [SELECT Id, title, Summary, KnowledgeArticleId FROM KnowledgeArticleVersion ...


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