on 2024 Oct 16 10:15 AM
Hello,
I have manually inputed "202309" in my input field and I have a dropdown with numbers 1 to 6 in it. The initial requirement was to add the dropdown numbers to the input field value. Lets say if I choose 2 in dropdown the input field will show 202311 as a result. I used the below code and it worked fine.
var before_LC=ConvertUtils.stringToNumber(InputField_9.getValue())+ConvertUtils.stringToNumber(Dropdown_2.getSelectedKey());
ScriptVariable_1 = before_LC.toString();
Now the requirment is that I need that input field to read that value (202311) as a date dimension ID so that later I can have a date dimension member description for the value (which would be Nov 2023).
Do we have any script for that?
Any support would be appreciated.
Thanks
Request clarification before answering.
The easiest way I can think of achieving this will be using the getmember() of the Datasource. If you have a table or a chart, you can just use the datasource of it to get the description of the member and then combine it with Year from Scriptvariable 1. I am assuming you have already done the required manipulation and your ScriptVariable1 is assigned "202311"
You can use something like below
ScriptVariable_1="202411"; // Assuming this is assigned by previous logic
var DS= Table_2.getDataSource();
var Year =ScriptVariable_1.substr(0,4);
ScriptVariable_2=Year+ " " +DS.getMember("Date",ScriptVariable_1).description;
Output: I have assigned the ScriptVariable2 to dynamic Text Box which initially shows No value but on click of the button which has the above script
Hope this helps !!
Nikhil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @N1kh1l,
I really appreciate your answer but I think I missed on some further details.
The value "202411" is actually saved in an another input field bcz I needed a condition to be fulfilled while using the dropdown so actually "202411" would be a derivation.
Here I am getting "202403" and its desc "Mar 24" from the below code: (OnInitialization)
var z=Table_6.getDataSource().getMembers ("Start_Date",{accessMode:MemberAccessMode.BookedValues});
InputField_9.setValue(z[i].id);
InputField_10.setValue(z[i].description);
I want the second value to work the same way i.e. 202404 as Apr 24.
But here I am using a different code on the first dropdown OnClick to get my requirement fulfilled which is as below:
I moulded your given code according to the need and used it on OnIntialization in order to get "Apr 24" in the second box while opening the story page. But seems like the code is not working fine. Below is the code used:
Seems that there is no error in the script but it is not working.
Your help would be appreciated.
Thanks so much
User | Count |
---|---|
10 | |
9 | |
5 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.