Ignore Case When Comparing Strings

I have a beautiful script that was created for us by Dundas (sorry I don’t know the author’s name) that we’ve been using to set the view of our dashboards to only show the current user’s information. The problem I’m running into is that it’s case sensitive and I can’t figure a way around it. Some of our users in the system have been added as ALLCAPS, others as all lower and others still as CamelCase. How can I alter this script to match username regardless of case?

// In a view's (e.g., dashboard's) ready or load actions, use this rather than this.parentView:
var viewParameter = this.control.getViewParameterByName("viewParameter1");
// Remove all values and tokens from the parameter value
viewParameter.parameterValue.clearTokens();
viewParameter.parameterValue.clearValues();

// Below is an example of a member value from a flat hierarchy.
// Create a new MemberValue to push onto the values array.
var memberValue = new dundas.data.MemberValue({
"hierarchyUniqueName": "Associate + Username",
"levelUniqueName": "Associate + Username",
"memberKind": dundas.data.MemberKind.REGULAR,
"uniqueName": dundas.context.currentSession.accountDisplayName + " (" + dundas.context.currentSession.accountName.split("\\")[1] + ")"
});
viewParameter.parameterValue.values.push(memberValue);
// Set the last modified time so this parameter takes precedence over any others
viewParameter.invalidateParameterValueLastModifiedTime();
1 Like

Hi,

You can compare by converting them to upper case or lower case like this: “USER1”.toUpperCase() == “User1”.toUpperCase(). It will return ‘true’ if they match, irrespective of their cases.

@upasana, I’m not sure how to add that comparison to the script. Where would that go?

Hi,

I thought you just needed to compare them.
What case should the values of properties hierarchyUniqueName, levelUniqueName and uniqueName should be in - lower case or upper case? To have either of them, just change the case of the values during assignment like “Associate + Username”.toLowerCase() or dundas.context.currentSession.accountDisplayName.toLowerCase(). Is this your requirement?

1 Like