I am trying to define a set of actions for a user based on salesforce picklists.
I have a main field called fHCM2__Reason__c that is a picklist containing multiple absence reason types - Sickness, Annual Leave etc
I then have a related field called Annual_Leave_includes_a_trip_abroad__c that is a picklist with two possible options - Yes or No
I want to define that if a user selects "Annual Leave" from the fHCM2__Reason__c picklist they cannot leave the field Annual_Leave_includes_a_trip_abroad__c blank and have to choose Yes or No.
Currently I have the below:
ISPICKVAL(fHCM2__Reason__c, "Annual Leave")
&& ISBLANK(Annual_Leave_includes_a_trip_abroad__c)
My problem with my current method is that because Annual_Leave_includes_a_trip_abroad__c is a picklist, that has "Yes" or "No" options, this is causing an error as I cannot see how to define this in the above PICKVAL() statement.
Can anyone advise how can I state that if a user choose "Annual Leave" then they have to provide a value (Yes or No) for the Annual_Leave_includes_a_trip_abroad__c field if they choose Annual Leave?
The function ISBLANK() takes an expression. A picklist needs to be "unpacked" with TEXT() to be considered an expression. Your validation rule should be:
ISPICKVAL(fHCM2__Reason__c, "Annual Leave")
&& ISBLANK(TEXT(Annual_Leave_includes_a_trip_abroad__c))
Source (see the section on ISBLANK():
If you use this function with a picklist, use ISBLANK(TEXT()) to
convert the picklist items into a text value.
Bear in mind that if you are using this in a custom object (including a custom object that is part of a managed package released by Salesforce, like some parts of Health Cloud), you can use Dynamic Forms to render fields conditionally, and making the field to appear and be required when the right value of the initial picklist is selected, and hidden otherwise.
In general, it's a good idea to avoid creating validation rules when other alternatives that do not stop the users' flow are available.
Related
I have content type award with few fields (user, position, lesson).
I have create a rule to create new node in rule actions.
When i select node type in rule it's show only two fieds : title and author.
How i get all other fields in rules action or condition .
Thanks
You have to create additional actions to set data values for the additional fields you want filled in.
It looks like (part of) what you're trying to do, is to add a Rules Action like "Set a data value" for the fields you mentioned (like lesson, etc).
But before you will be able to create a Rules Action like "Set a data value" for your field(s), you have to make sure to add a Rules Condition Entity has field (related to the field for which you want to set a value). And make sure to add that Entity has field condition BEFORE other Rules Conditions in which you might want to refer to this field. Depending on what exactly you want to do in your custom rule, an alternative might be to use content is of type.
That's also what is mentioned in the Rules UI, e.g. when you're adding a "data comparison" condition: somewhere it says:
The data selector helps you drill down into the data available to Rules. To make entity fields appear in the data selector, you may have to use the condition 'entity has field' (or 'content is of type').
For a video tutorial that illustrates the importance of this Entity has field condition, refer to Data types and data selection, especially what is shown between about 13:30 and 17:30 in it.
I wanted to add a simple read-only URL-field to 'opportunities' in SalesForce that contains a link to an external webpage with the 15-char record id (used in the salesforce urls) attached to it . To do this I wen to /ui/setup/Setup?setupid=Opportunity --> fields and created a new field under 'Opportunity Custom Fields & Relationships'.
I chose a field with data type 'URL' and added a default value. I thought
"http://example.com/?sfid="&id would do the trick, but this returns
Error: Field id may not be used in this type of formula
This is a vague error. Is my syntax of a default value wrong, or am i using the 'id' parameter in a wrong way? And what is the right way to do this?
I'm new to SalesForce, as you probably already have guessed.
As the other answer stated - Id will be known only after insert meaning the "default value" trick won't work for you.
You have some other options though:
Workflow rule that would be populating the URL field after save.
Formula field of type text that uses HYPERLINK function
HYPERLINK("http://example.com/?sfid=" & Id , "See " & Name & " in ext. system")
Custom link (similar to custom buttons, they appear on the bottom of the page layout. Search them in online help)
The difference between 2 and 3 is quite minor. Custom links can appear only on the record's detail view while formula fields & other urls are well... fields - so they can be used in reports, listviews etc.
You'd have to decide which version suits you best.
This is a great question. You're right, the error is very vague.
To begin with, read some of the documentation on default fields. Pay particular attention to the order of operations:
The user chooses to create a new record.
Default field value is executed.
Salesforce displays the edit page with the default field value pre-populated.
The user enters the fields for the new record.
The user saves the new record.
Default field values are calculated before any other record data including the id are available. For this reason, they cannot be calculated based on other record fields. Especially the record id, which has not yet been assigned.
To get this functionality, you will need to create a workflow rule that fires on record creation and inserts the proper value into your field.
It would be nice if we could have formula URL fields, but we don't. EDIT: I am dumb and forgot about using HYPERLINK in text formula fields, as eyescream correctly points out.
I am using salesforce for a group project here at SJSU, the thing is this is our first time using it, and we are having a little bit of trouble programming some things on Salesforce.
What we are trying to do:
We have a section on one of our forms where users will give us authorization to use Data they submit, the usage of this data will be under the terms set by those who submit the data. If the user does not want to set limitations on their authorization for us to use the data then they can select a checkbox called labeled "none" which basically means they are setting no limitations on what we can use their data for.
What we want to do is, if users select the checkbox then we want the users to not be able to enter any text into the textbox. If users enter text into the box while the checkbox is checked we want an error message to appear which will let the user know that no data can be entered into the box if the checkbox is checked. However if no checkbox is checked then we want users to be able to enter the data. How do we go about doing this
AND (None_c = True then Limitations_c has to be empty, elseif None_c = False then Limitations_c cannot be empty.)
If you want to leverage the out of the box UI (Page Layout), then you will likely want to use Validation Rules.
https://help.salesforce.com/HTViewHelpDoc?id=fields_defining_field_validation_rules.htm&language=en_US
The gist of it is that you want to define Error criteria, so when this criteria evaluates to true, and error is thrown. In that case, you should be able to construct something similar to the following:
Checkbox1__c && NOT(ISBLANK(Text2__c))
Validation rules would be the easiest way to execute this, though checking the box would not dynamically prevent users from entering text. With a validation rule, it just wouldn't let a users save.
The nice thing about using validation rules is that you can construct them such that checking None__c will not vomit on the user unless they actually modify Limitations__c. ISCHANGED() is great for that.
If I could suggest an alternative, the way I would implement this is to treat an empty Limitations__c as None__c = True. It simplifies things for users, and you can add a formula-driven checkbox if a checkbox element is truly required.
I am new to Salesforce and need an idea how is possible that suppose I have one user named "ABC".I don't want to show the Opportunity StageName picklist when "ABC" user login in editable form or just want to show the StageName value in textfield or anything other.
I tried to set the permission under setup but not achieved what I want. I just came to know that formula field or formula will used for that, as I am new to Salesforce so I unable to create a formula field.
Thanks.
To achieve this You should try field level security settings:
https://login.salesforce.com/help/doc/en/admin_fls.htm
You can select per field /profile combination which fields are visible and which are editable.
You cannot apply FLS on system required fields neither can you make them read only on the page layouts. You also cannot remove such fields from page layout. In short you are stuck with this field for ever!
I wish Stage was not a required field.
Mitesh
Using PDF, is it possible to create a single form element with multiple fields of which several can be selected? For example, in HTML, one can create a set of checkboxes associated with the same field name:
<div>Select one for Member of the School Board</div>
<input type="checkbox" name="field(school)" value="vote1">
<span class="label">Libby T. Garvey</span><br/>
<input type="checkbox" name="field(school)" value="vote2">
<span class="label">Emma N. Violand-Sanchez</span><br/>
In this case, the field name is "field(school)", and when the form is submitted, "field(school)" can be supplied 0, 1, or 2 times.
Is there an equivalent construct in PDF where a single field can have multiple values. So far in my investigation, it appears that if fields are assigned the same name, it is only possible to select one field. If it is possible to implement this in PDF, what is this construct called and how can it be implemented?
Edit: To clarify, I am aware that a PDF can contain multiple form fields with different field names, and those can be selected independently, but then the grouping is implicit and not explicit as with the HTML form. I would like to use a construct that makes the grouping of options explicit, and preferably allows for restrictions (e.g. at least one required, no more than 2 allowed, etc).
Edit: If someone can find an authoritative opinion that this is not possible, that would also be a desirable answer.
Yes it is possible. In Adobe PDFs you have the checkbox concept and the radio button concept. While each checkbox and radio button can have its own name, however, they can also be grouped through a subtier via the GroupName.subobj.
Adobe describes it as follows:
The field name. This may include
hierarchical syntax in order to
facilitate logical groupings. For
example, the name myGroup.firstField
implies that the form field firstField
belongs to a group of fields called
myGroup. The advantage of creating
logical hierarchies is that you can
enforce consistency among the
properties of related form fields by
setting the properties of the group,
which automatically propagate to all
form fields within the group.
When the fields are set via a hierarchy you can then get the value of myGroup in this case, and return the selected value of the group. Similarly in the case of RadioButtons you would make sure that all fields in a group have the same name.
This approach to creating form fields
is applicable to all fields, but it
should be noted that radio buttons
require special treatment. Since a set
of radio buttons represents a set of
mutually exclusive choices, they
belong to the same group. Because of
this, the names of all radio buttons
in the same group must be identical.
In addition, the export values of the
set of radio buttons must be set with
a single statement, in which an array
of values are assigned by the
exportValues property of the Field
object. For example, suppose we would
like to create a set of three radio
buttons, each 12 points wide and 12
points high, all named myRadio. We
will place them on page 5 of the
document, and their export values will
be Yes, No, and Cancel. They can be
created as shown in the code given
below:
var name = "myRadio";
var type = "radiobutton";
var page = 5;
var rb = this.addField(name, type, page, [400, 442, 412, 430]);
this.addField(name, type, page, [400, 427, 412, 415]);
this.addField(name, type, page, [400, 412, 412, 400]);
rb.exportValues=["Yes", "No", "Cancel"];
asnyder's response led me to the conclusion that there is no automatic way to handle multiple values within a single field (as one can with HTML). asnyder's examples come from Developing Acrobat Applications Using JavaScript, available from the Acrobat Javascript Developer Center. This document provides some examples of how to manipulate checkboxes, combo boxes, and radio buttons. All of the examples shed some light on the problem and ultimately led me to the conclusion that any system that is using PDF forms will have any multi-selectable groups implicitly defined.
Using the construct of groupName.fieldName appears to be useful to manipulate the widgets as a group (in Acrobat Javascript), but the fields of a group cannot be enumerated (without enumerating all fields and filtering for the groupName), and the collective value of that group cannot be determined without programatically inspecting the values.
In other words, a multi-selectable value is not an intrinsic feature of Acrobat nor of PDF in any substantial way, though it is possible to implement such a form through programming.