Question

call methodName attribute with a argument

Hey

I am using calculated fields to convert inches to cm and vice versa on a lot of different measurements. I am just wondering if I am able to put a variable name when called the methodName so I wouldn't need to create a bunch of methods for each separate one.

Example

			"UsrLengthCM": {
				dataValueType: Terrasoft.DataValueType.FLOAT,
                dependencies: [
                    {
                        columns: ["UsrLengthInches"],
                        methodName: "calculateInchesToCM"
                    }
                ]
			},

do something like this is what I want

			"UsrLengthCM": {
				dataValueType: Terrasoft.DataValueType.FLOAT,
                dependencies: [
                    {
                        columns: ["UsrLengthInches"],
                        methodName: calculateInchesToCM("UsrLengthCM")
                    }
                ]
			},

to make it easier when using this.set

Like 0

Like

3 comments

The method will get passed two parameters, the second parameter is the field that triggered the event. You could use something like this:

calculateLength: function(sender, field) {
    switch(field) {
        case "UsrLengthCM":
            // ...
        case "UsrLengthInches":
            // ...
        // etc
    }
}

Not sure if that's something that will help, but thought I'd mention it.

Ryan

Ryan Farley,

Exactly what I need thank you!

Ryan Farley,

 

Thanks Ryan, this is the only thread I have found that highlights the fieldname being passed from the Attribute dependency. V.Useful!

Show all comments