cancel
Showing results for 
Search instead for 
Did you mean: 

How can dissable a button depend of a variable

I816327
Advisor
Advisor
0 Kudos

Hi experts,

I have the follow situation:

I create a wad where I need to specified a Level Variable.

Zlevel = 20

When the wad is executing I display 3 button, one of them is "obtain from level before'. That's fine.

So, when I select Zlevel = 10, I need that the button "obtain from level before' to be Dissable beacouse I don't have any level before.

This problem is led beacouse I'm trying to reuse the WAD.

Someone Knows how can resolve that, without create a copy of WAD.

How can do that in a WAD code??..

I will appreciate any suggestions...

thanks

Regards,

Lcvc

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi

If you have Zlevel value in your Script you can easily disable it

Include your script item into WAD and create a script with command wizard

set the item properties of the button to disable and save your command

You will get Javascript code generated automatically. use the variable Zlevel before any command is set.

your function should be like this

function executeABD(currentState,commandSequence)

{

if(Zlevel == 10)

{

code generated by system except return statement.

}

return sapbi_page.command();

}

Now you can use this anywhere as an action command.

But remember, you can only do this if you have Zlevel in your Javascript.

Try with a constant condition first and try to get Zlevel into Javascript

Cheers

Sri

I816327
Advisor
Advisor
0 Kudos

Hi Sri,

Thanks for your answer, but it doesn't work yet.

We follow the next steps:

1.- We insert a script code object.

2.- We wrote the code (see below).

3.- We set in a button object a command.

With REleaseAction : on

Release_Action

Action: Function Script

Function Script: execute JS_SET_ITEM_PARAMETERS_R..

4.- We associated the script object in a WAD.

I gona show you the code that we used on Script code:

function executeJS_SET_ITEM_PARAMETERS_R( currentState, defaultCommandSequence )

{

/* Create a new object of type sapbi_CommandSequence */

var commandSequence = new sapbi_CommandSequence();

var commandSET_ITEM_PARAMETERS_1 = new sapbi_Command( "SET_ITEM_PARAMETERS" );

/* Create parameter ITEM_TYPE */

var paramITEM_TYPE = new sapbi_Parameter( "ITEM_TYPE", "BUTTON_GROUP_ITEM");

commandSET_ITEM_PARAMETERS_1.addParameter( paramITEM_TYPE );

/* End parameter ITEM_TYPE */

/* Create parameter INIT_PARAMETERS */

var paramINIT_PARAMETERS = new sapbi_Parameter( "INIT_PARAMETERS" );

var paramListINIT_PARAMETERS = new sapbi_ParameterList();

commandSET_ITEM_PARAMETERS_1.addParameter( paramINIT_PARAMETERS );

/* Create parameter BUTTON_LIST */

var paramBUTTON_LIST = new sapbi_Parameter( "BUTTON_LIST", "" );

var paramListBUTTON_LIST = new sapbi_ParameterList();

/* Create parameter BUTTON */

var paramBUTTON2 = new sapbi_Parameter( "BUTTON", "" );

var paramListBUTTON2 = new sapbi_ParameterList();

/* Create parameter ENABLED */

var paramENABLED = new sapbi_Parameter( "ENABLED", "" );

paramListBUTTON2.addParameter( paramENABLED );

paramBUTTON2.setChildList( paramListBUTTON2 );

paramListBUTTON_LIST.setParameter( paramBUTTON2, 2 );

paramBUTTON_LIST.setChildList( paramListBUTTON_LIST );

paramListINIT_PARAMETERS.addParameter( paramBUTTON_LIST );

paramINIT_PARAMETERS.setChildList( paramListINIT_PARAMETERS );

/* Create parameter TARGET_ITEM_REF */

var paramTARGET_ITEM_REF = new sapbi_Parameter( "TARGET_ITEM_REF", "BUTTON_GROUP_ITEM_1" );

commandSET_ITEM_PARAMETERS_1.addParameter( paramTARGET_ITEM_REF );

/* End parameter TARGET_ITEM_REF */

// Add the command to the command sequence

commandSequence.addCommand( commandSET_ITEM_PARAMETERS_1 );

/* End command commandSET_ITEM_PARAMETERS_1 */

//Send the command sequence to the server

return sapbi_page.sendCommand( commandSequence );

}

Do you have any Suggestions about??

I will appreciate any comment..

Thanks