0

In advance, thank you for your help.

What I am trying to do is to create the following validation rule (whether it will be an actual validation or a javascript API validations, that remains to be determined).

The validation rule or code will have to do the following:

Only allow a user to click on the "NURF" button if AND ONLY if the New Hire Start Date field is populated and not "NULL"

Here is my code as it was before, I just need to add the correct validation rule as outlined above:

{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}
var Contacts = new sforce.SObject("Contact");
Contacts.Id = '{!Contact.Id}';
Contacts.Recruiting_Status__c = 'NURF Initiated';
Contacts.Workflow_Trigger_FOR_NURF__c = '1';

var result = sforce.connection.update([Contacts]);

if (result[0].success=='false') {
     alert(result[0].errors.message);
} else {
     location.reload(true);

Thanks guys and gals.

1

This seems too easy so I hope i'm not missing something here

Add this validation rule to Contact:

ISBLANK(new_hire_start_date__c)

when the update happens on the button's javascript, the user gets an error

If this NURF button is on a VF page bound to Contact, you could conditionally render it with a render="{!NOT(ISBLANK(contact.new_hire_start_date__c))}"

  • Well I understand what the code needs to be (in terms of the qualification/validation) but what I am curious about is where I need to put that code and if I need to preface it with any syntax in order to be a validity argument. – Scott Brady Nov 24 '14 at 20:07
  • The Validation rule goes onto the SObject Contact using Setup | Customize | Contacts | Validation Rules – cropredy Nov 24 '14 at 20:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.