I have to make a field read only after user has entered value in salesforce so that even that particular user cannot change the value once its entered. How could i achieve this. Thanks in advance.
To my knowledge, Salesforce does not have a "allow this field to be set only once" setting. Simplest way would probably be a validation rule that only throws an error when the field is changed and the field's previous value wasn't blank, something like:
AND(
ISCHANGED(SomeField__c),
NOT(ISBLANK(PRIORVALUE(SomeField__c)))
)
Or for a picklist:
AND(
ISCHANGED(SomeField__c),
NOT(ISPICKVAL(PRIORVALUE(SomeField__c), ''))
)
Related
I need to write validation rule on account, which will check valid country name from other pick list filed in exits in same object. In case that country name does not match from other country picklist then error should be displayed at account.
Thanks,
Satya
You can try the below
TEXT( Field1 ) != TEXT( Field2 )
There are several functions available to use. You can find them while creating the validation rules.
Using sales force i want to update a custom field value with the value of the account name using workflow ,i have created the custom field named (Name__c) and also the workflow but i don't know what is the data i should fill the workflow with to update this value to make the account name as a unique but i could not find the exact steps i should make to perform this action
and also i have used
ISNEW() || ISCHANGED(Name) || ISBLANK(Name__c)
but i got an error message said "Error: Function ISNEW may not be used in this type of formula"
sorry as i am new in sales force technology
Mark the custom field named (Name__c) as UNIQUE in custom field definition.
Set the Rule Criteria : Name(standard field) not equal to null.
Evaluation Criteria : Evaluate the rule when a record is created, and any time it’s edited to subsequently meet criteria
Add the field update workflow action to copy the Name to Name__c
I want to set newsletter flag to 2 in database table, but when I do this $this->data['User']['newsletter'] = 2; It always sets to 1. Its a checkbox on registration page. Can anybody help me how to set it to 2.
Thanks!
If it is a checkbox, you got your newsletter field to tinyint(1). which is a boolean representation of yes/no, 1/0.
SO either you only want to store a boolean value (and therefore the checkbox in the view) or you need to change your field to tinyint(2) to allow some kind of enum (more than just two definite states). But then you also need to use a select here in the view.
So what exactly are you trying to do? You can't have it both ways.
What I am looking to do is Make it the "Account" name field require a unique name.
Basically If one of my reps tries to create an account, and that account all ready exists it tells them no that account all ready exists.
Salesforce tells me this funicality is not build into sales force. Any help or dirrection would we wonderfull.
Make a new text field, call it Name__c. Mark it as unique, length... probably 80, same as Name field length.
Create new Workflow rule with condition ISNEW() || ISCHANGED(Name) || ISBLANK(Name__c) and the action should be a field update that simply has Name in the formula that determines new value.
Remember to activate the workflow and to fill in the newly created field because it will be blank for all your existing accounts!
Your call if you want to show the field on page layouts (it's quite "technical" so could be hidden). If you do - it's a good idea to make it readonly!
You can use this validation:
AND(CONTAINS(VLOOKUP( $ObjectType.Account.Fields.Name , $ObjectType.Account.Fields.Name, Name), Name), OR(ISNEW(), ISCHANGED(Name)) )
Salesforce offers duplication management for this purpose.
You just set up Matching Rules and Duplicate Rules for your Account object in Setup > Administration Setup > Data.com Administration > Duplicate Management.
Link: https://help.salesforce.com/apex/HTViewHelpDoc?id=duplicate_prevention_map_of_tasks.htm&language=en_US
You could write a trigger to prevent duplicates. It'd be a "before insert" trigger that queried for existing accounts with the same name. If an Account name already exists, you'd call addError() on the new Account record, preventing the insert from continuing.
Have you searched the AppExchange for solutions? Might want to check out something like DupeCatcher
You could always make a custom field to contain the account name (something like "Business Name") and then ensure that's required and unique.
You'd need to do some basic Data Loader gymnastics to move your account names to the new field, and come up with a strategy for populating the existing Name field for accounts.
AND(VLOOKUP($ObjectType.Object_Name.Fields.Name, $ObjectType.Object_Name.Fields.Name, Name) = Name, OR(ISNEW(), ISCHANGED(Name)))
SOQL query not returning rows on visualforce page that do exist in object I am having issues retrieving records which exist from an object via a SOQL query on a visualforce page
How do I know they exist? I have used force explorer and workbench and the following returns a record
SELECT Code__c FROM External_membership_label__c WHERE Code__c = '3'
OK, so the visualforce page does not return the record above, with the code below (few lines from code)
public String gvlLCCODE {get;set;}
if(gvlLCCODE != null || gvlLCCODE != ''){
List<External_membership_label__c> exisitingGVLcodes = [SELECT Code__c FROM External_membership_label__c WHERE Code__c = :gvlLCCODE];
if (exisitingGVLcodes.Size() > 0){
//blahh blahh
}
}
Any suggestions? I have debug telling me 'gvlLCCODE' has a value that exists in the object. Also, if I change the SOQL to say, for example, return the current user from the users table, it returns a record and then enters the IF statement.
I think its a security issue I have missed. But I have also checked these.
Thank you
well, for one, in your IF statement you probably want to use &&, instead of ||.
Are you having the problem with the test method? if so, then it's because that method doesn't have access to the existing records by default.
First of all you should listen to Kirill about the &&, both condtions should be met, not just one. Likewise, the || is meaningless, formula (a!=b)|(a!=c) is always true for any a when b!=c as is the case here
Second, it sounds as you definitely have a security issue here. To verify change extension's declaration from with sharing to without sharing and run. If you get the row you have sharing security issues with the row.