I am using the following lines of code in my VF page to open the URL & it's opening in the same tab but I need to open a new Tab as soon as clicking the custom URL Button?
<apex:commandButton action="{!URLFOR($Action.My_Obj__c.My_custom_link)}" value="My custom button"/>
I don't think I have ever seen a button that opens something as new tab/window? Link yes, but not button. Think if that's really what you want, user might be surprised with unexpected behaviour.
Try using <apex:commandLink action="{!URLFOR($Action.My_Obj__c.My_custom_link)} target="_blank">. You could style it to look like button by looking at class names (both in Classic and Lightning Experience).
If that doesn't work - worst case you can always capture onclick and do window.open or whatever from there...
Related
So I have a button in which when I hover over it, it will automatically click a link somewhere else in the site.
Is there anyway to do this in angularjs?
In angular js use ng-mouseenter which will trigger automatically when you hover to your element
<div>
<input type="button" value="value" ng-mouseenter="link" />
{{link}}
</div>
You can use ng-mouseenter, but you need to provide an expression, if you use just the link (like in the answer above), nothing will happen.
It will be something like:
<button ng-mouseenter="openLink('yourLink')">Value</button>
And you javascript function will be something like:
$scope.openLink = function(link){
window.open(link)
}
However, I will not recommend you to do something like that. Opening links on hover will really hurt the user experience of your site and actually, if the link is opened in a new window or a new tab will completely depend of your user's preferences in their web browser (and the popup might end up being blocked). In my opinion, if you want to open a link, just use an explicit link that your users can click on it, or use a redirect when necessary.
I'm trying to put a checkbox in a salesforce page but the problem is that the required message is more than 40 characters so it doesn't fit in the checkbox label (40 character max)
I tried adding two custom fields on top of the checkbox but the problem that these fields even though if they are read only the user can edit there content(text(255)) or not be able to see them(formula(text)) in edit mode.
Is there any way I can do that without creating a custom page and appending it in the page?
It isn't an ideal solution but you could create a new section on your page layout which will allow more text than a label to be displayed. Then only put your confirmation check box field in that section.
That will affectively give you the long label description you are looking for.
You can create a very simple Visualforce page:
<apex:page standardController="Account" showHeader="false" sidebar="false">
I confirm that the new account is open
</apex:page>
Set the controller to your object; I use "Account" here.
You then insert the Visualforce page directly into the page layout, just like you would a field.
It sounds like you need visualforce or S-Controls (now deprecated)
An alternate is to make a text box and prepopulate it with the info, but I think that too would need those technologies
If you come up with a solution to this- let me know.
I have a situation where I need to convert input text to upper case. As soon as we type some text in the input field it needs to convert it to Upper case.
We have following css style for this:
style="text-transform: uppercase"
Using this style, text is entered in Upper case automatically so we don't need to do anything extra, but there is no option in Salesforce to add style to a field.
Is there any way to accomplish this?
Unfortunately, there isn't an easy way to add a CSS style to a field appearing on a Standard Page Layout in edit mode. However, there are some options (listed below) you may want to explore.
Visualforce
You can add a style attribute to an [inputtext] in Visualforce (http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_inputText.htm) or inputfield component.
<apex:inputtext value="{!Widget__c.Name}" style="text-transform:uppercase;" />
To add a CSS class instead, you can use the styleClass attribute. I believe this affects only the display of the text data, though. To make sure the value is uppercase when saved to the database, use this JavaScript on the onkeyup attribute (below).
<apex:inputtext value="{!Widget__c.Name}" style="text-transform:uppercase;" onkeyup="var u=this.value.toUpperCase();if(this.value!=u){this.value=u;}" />
Standard Page Layout
Option 1: Embedding a Visualforce Page in a Standard Page Layout
To do this on a Standard Page Layout, you could create a Visualforce Page for the field you would like this functionality on. This however will show up on View of the record only. It will not be visible on Edit.
The Visualforce Page would look like this (where Widget__c is replaced by the sObject you're working with):
<apex:page standardController="Widget__c">
<apex:form id="WidgetForm">
<apex:actionFunction name="SavePost" action="{!save}" rerender="WidgetPanel" status="str" />
<apex:outputpanel id="WidgetPanel">
<apex:inputtext id="WidgetName" value="{!Widget__c.Name}" style="text-transform:uppercase;" onkeyup="var u=this.value.toUpperCase();if(this.value!=u){this.value=u;}" />
<apex:commandbutton value="Save" styleClass="btn" onclick="SavePost();" />
<apex:actionStatus startText="Loading..." stopText="" id="str"> </apex:actionStatus>
</apex:outputpanel>
</apex:form>
</apex:page>
Then on the Page Layout, click the Visualforce Pages category underneath Fields and Buttons, and add your Visualforce page to your Page Layout by dragging the Visualforce Page component to the Layout. Be sure to configure the height of it by clicking the wrench in the top right of the new Visualforce Page component.
Option 2: Use JavaScript on a Standard Page Layout with a Sidebar Component
Another, more complicated, option for working with a Standard Page Layout would be to add a Home Page Component on the Sidebar that contains JavaScript. This option requires a fair understanding of JavaScript (or jQuery a JavaScript library). The JavaScript could then find the field, add the text-transform:uppercase; style to it, and bind a function to the keyup event to convert all inputted characters to uppercase (element.value.toUpperCase();). For more information on this method, check out Tehnrd's blog post on adding a sidebar component for JavaScript. He uses this method to show and hide buttons on Standard Page Layouts, but it could be modified to suit your purposes.
I was wondering if there is a way to override the native functionality of the lookup field in Salesforce and replace it with a visualforce page. The reason I'm trying to override this button is because when the user does a look up, the look up returns everybody with that name. What we want to return is a list of all the contacts by account for the contact being searched.
Here's what I'm trying to achieve:
When the user clicks the lookup button my visualforce page will launch and allow the user to see the account and all the contacts of that account.
Is this even possible? What other ways would you suggest going about this?
Here's a screen shot of what I'm trying to change:
Thanks for all your help!
It sounds really like you just need to customise the columns on the lookup to make it better suited to your needs. If you go to Setup -> Customize -> Contacts -> Search Layouts, you'll see entries for Lookup Dialogs and Lookup Phone Dialogs, there you can edit the columns displayed in the lookup windows.
If you really need a custom solution:
You can't override the lookup page itself, but you could create a new visualforce page for your account, using <apex:detail> and other similar tags to make your life simpler. Then you could include a search section underneath, where a user can enter various search terms which you put into a dynamic SOQL query and then render the results for them to choose from.
yeah its possible by javascript as i did by visual force page that will show the records of related lists and upon selection id of that record passed to parent window by jscipt. and performed same functionality ..
As far as I know - NO.
As a workaround you can use JavaScript.
What we did in our situation? We implement everything in JavaScript. We created an inputText and right on the right of this inputText we placed image with this lookup icon. On image click we create ExtJS popup window (I think you can simply create VF page and show this page in popup window). After window was closed you fill in the inputText field.
There's no out-of-the-box override for this button, last I checked, so something custom would be required. If you're set on having a popup and do not want an inline solution, I'd recommend reviewing this tutorial to get familiar with some of the issues with popups in Visualforce.
But considering what you are looking to accomplish, you could also have your account and filtered list of all contacts associated with that account appear inline on your page when the user clicks a new, custom search button. Of course that page would itself be in Visualforce (or inline Visualforce in a standard page layout) - which you may or may not want to have to code and maintain.
The AJAX Toolkit might also be a good place to start if you want to go with a custom JavaScript button placed on a standard page layout.
I want to show a popup of list of cases without parentid and allow to select usign checkbox and the selected cases are added up in a related list. This popup would be availabe on clicking of link button
First question would be can i call a vf page as popup from a standard page? The rest i guess i can hande it in the VF page
Thanks
Prady
Yes, you create a link button for the object in whose page layout the link will reside. As a source for the link button choose "Visual force page" and choose a page. Keep in mind that the vf page MUST use standardController for the same object (with or without extensions) or it will not show up in the list. Choose to show the page in a new window and later place the link button on the page layout.