cancel
Showing results for 
Search instead for 
Did you mean: 

Template inclusion/Javascript issue for doc header's custom fields

matteo_montalto
Contributor
0 Kudos

Hi all gurus,

premise: I'm absolutely a newbie about templates and Jscript.

I'm facing a strange behaviour for a field and I'd like to get your help on it, I'm running out of ideas.

I modified a custom field, a checkbox, which automatically makes a second custom field active and editable.

The logic is really simple: if the checkbox ( ZZ0LEGGE ) is checked, then the second field ( ZZ0DESCR ) is editable.

This is managed in the template by using a Jscript function that is triggered by the event OnClick related to the checkbox.

These two field are part of a template, say T1, which is used as an include in a pair of "main", custom templates, say T2 (additional header custom data) and T3 (document variant). These two screens are custom on an old SRM3 system.

When working on the additional header custom data (Template T2), both buttons work fine; each time the checkbox is checked/unchecked, the screen is updated and the second field turns into active/not active as consequence.

Working instead on the document variant screen (Template T3) leads to a wrong behaviour.

Checking/unchecking the checkbox doesn't refresh the screen accordingly to the selection, but loads the T2 template.

Guess there's something missing on the Javascript fuction associated with the checkbox in T1, because it will always trigger a refresh of T2, no matter the template in which it is included.

Here are the templates:

Template T1: [SAPLBBP_PDH_CUF 100 |http://pastebin.com/U39i5j7N]

Template T2: [SAPLBBP_CTR_UI_ITS 9001|http://pastebin.com/3AhKRjt7]

Template T3: [SAPLBBP_CTR_UI_ITS 9003|http://pastebin.com/4ZHtjz0r]

The checkbox field in T1 is called ZZ0LEGGE; the "controlled" field is instead ZZ0DESC.

Waiting for your help... thanks once again

Accepted Solutions (0)

Answers (2)

Answers (2)

matteo_montalto
Contributor
0 Kudos

Solved. .)

matteo_montalto
Contributor
0 Kudos

Ok I found an interesting starting point to focus on... I changed the simple fuction associated to the event onClick(), triggered when the checkbox is set/unset, simply using the parameters for TargetOkCode used in Template 3:

function zOkRefresh(){
        TargetSetOkCode('`PB_OKCH.okcode`','','`bbpformname`'); //new (works for T3)
//        TargetSetOkCode('=ZCTR_CUST1','','BBPForm');                //old one (worked for T2)
 }

and now the checkbox works properly in Template 3 but - obviously - stops working in Template 2.

So it seems that zOkRefresh should dynamically decide which parameters must be used, depending on the "upper" template:

- if the template that includes T1 is T2, then call TargetSetOkCode('=ZCTR_CUST1','','BBPForm'); if T1 is used in T3, then call TargetSetOkCode('`PB_OKCH.okcode`','','BBPForm').

Since I'm not able to write down the script described above, can anyone help me putting that IF statement in script code? How to determine what's the "including" template in Javascript?

Thanks again!