Skip to main content

Hi,  

I have been trying to get the following to work with no success.

I am trying to make the Hyperlink field a required field based on if another field has a certain status.

For example:

Status is a choice field with the choice of 'Pending', 'Approved', 'Cancelled'

MyLink is a hyperlink or picture field/

I want MyLink to be required if Status is 'Approved'.

Here's my formula that I added in a Rule (with Rule Type: Validation) on the MyLink field, which does not work:

Status=="Approved" && isNullOrEmpty({Self})

it looks like either rules are not supported on hyperlink control or there is a bug.

I can't  find any mention that rules wouldn't be supported for hyperlinks, so I would vote for a bug.

the fact is that hyperlink control doesn't appear among named controls.

however if you build a formatting rule on hyperlink control using {Self} placeholder, it works.

but if you turn the same rule into validation one it doesn't works (respective rule script is not registered among all the rules).

here I found similar question I can't seem to use a hyperlink field in a validation rule where it was resolved by custom validation. but since you need to condition it on other control that probably will not be an option for you.

so, you will probably need to write some validation in javascript or to reach to nintex support and ask for a fix.


Hi Marian,

Thanks for the quick response!  So based on the other similar question link you sent me, I was able to reverse it to do exactly what I needed!

So this is what I did (based on the other post)

Steps:

  1. In form designer, double click your Status control, in the Advanced section, change the Store Client ID in JavaScript variable to Yes, and in Client ID JavaScirpt variable name, key in Ticket_Status. Save the settings.
  2. Then double click on your Links control, in the Validation section, change the Use custom validation to Yes, in the Custom validation function key in ValidateHyperLink, and key in your Custom error message, Store Client ID in JavaScript variable to Yes, and in Client ID JavaScirpt variable name, key in Hyper_link. Save the settings.
  3. Click the Settings button in the ribbon to get to form settings.
  4. In the Custom JavaScript section, key in the below code. (Copy and paste the code in Notepad, then copy from Notepad to the Custom JavaScript box, to avoid pasting extra stuff copied from webpage)

 

  1. function ValidateHyperLink(args, validator) {
    var URL = NWF$('#' + Hyper_Link).val();
    var status = NWF$('#' + Ticket_Status).val();
    if (URL.length <= 0) {
    if (status == "Approved") {
    validator.IsValid = false;
    } else {
    validator.IsValid = true;
    }
    } else {
    validator.IsValid = true;
    }
    }

     5. Publish the form.


glad I could help.

consider marking the topic answered.


I am trying to do this exact thing, but for a checkbox (yes/no) field. I tried using this javascript, but it doesn't work. How can I adjust this for a checkbox, instead of a dropdown field?


Jennifer

the checkbox is a true or false check.  Add a calculated field to your form and in the formula add the checkbox field to see the value.  Then you can create your rule once you know what is being displayed.


Reply