cancel
Showing results for 
Search instead for 
Did you mean: 

Set field value dynamically using JavaScript

Former Member
0 Kudos

I'm creating a form on the SAP standard Adobe form F140_CUS_STAT_01.

In the "Document" column I have the requirement to display field REBZG if it contains a value, or BELNR if not.

I have done the following:

if ( data.CustomerStatement.ItemTable.TableOpenItem.REBZG.rawValue == null ) 
  {  data.CustomerStatement.ItemTable.TableOpenItem.REBZG.rawValue = 
     data.CustomerStatement.ItemTable.TableClearingItems.BELNR.rawValue; }

Unfortunately nothing happens. Is there something wrong with my syntax?; Should I be using a specific event? Do I have to treat the internal table fields differently?

Also, how do I debug javascript. I have tried both "Alert" and print to console, but neither has any effect.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Check if it is possible to pass from backend in the same way, i.e. if rebe2 is not there fill it with belnr.

Thanks,

Aravind

rakesh_m2
Contributor
0 Kudos

Hello EstiNZ,

For comparing null values comapre with null and "" like

if(this.rawValue == null || this.rawValue == "")

also try this.isNull == "True";

Check in which event you have placed it.

If that doensn't work, try this.

var fields = xfa.layout.pageContent(xfa.layout.page(this)-1, "field", 0);

var text;

for (var i=0; i <= fields.length-1; i++)

{

if (fields.item(i).name == "REBZG")

{

text = fields.item(i).rawValue;

}

if (fields.item(i).name == "BELNR")

{

if(text == null || text == "")

{

fields.item(i).rawValue = text;

}

}

}

Thanks,

Rakesh.