• Resolved Francis

    (@emolotel)


    Hello
    how do I get a calculated field, based on a field value and the association of a dropdown. An example:
    self

    fieldname1 = 9
    ?
    have the nearest dropdown value as given

    fieldname2
    dropdown = 5
    dropdown = 10
    dropdown = 20

    FieldName3 = 10

    clear?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @emolotel

    I’m sorry, I don’t understand your question totally. Do you want to return in the calculated field the dropdown choice (fieldname2) nearest to the number entered into the fieldname1?

    If it is the case the equation would be similar to:

    
    (function () {
    	var field = getField(2),
    	values = field.choicesVal,
    	diff = Infinity,
    	result;
    	for (var i in values) {
    		if (ABS(values[i] - fieldname1) < diff) {
    			diff = ABS(values[i] - fieldname1);
    			result = values[i];
    		}
    	}
    	return result;
    })()
    

    Best regards.

    Thread Starter Francis

    (@emolotel)

    Sorry I expressed myself badly.
    Example:

    fieldname42 = x (calculated field)
    fieldname82 (dropdown)
    value = y
    value = z
    value = w

    It is necessary to have a calculated field that gives me (q):
    if x = 10
    y = 8
    z = 11
    w = 15

    q = 11

    if x = 12

    y = 8
    z = 11
    w = 15

    q = 15

    thank you

    Plugin Author codepeople

    (@codepeople)

    Hello @emolotel

    If you want as the equation’s result the element from the list greater than or equal to the number entered by the user, the previous code should be edited as follows:

    
    (function () {
        var field = getField(2),
        values = field.choicesVal;
        for (var i in values) {
            if (fieldname1 <= values[i]*1) return values[i];
        }
        return fieldname1;
    })()
    

    I’m sorry, but the support service does not cover the implementation of the users’ projects (forms or formulas). If you need additional support implementing the equations in your form, I can offer you a custom coding service from my private website:

    https://cff.dwbooster.com/customization

    Best regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘relationship between fields’ is closed to new replies.