Java Script for AP20.1

 7 Replies
 0 Subscribed to this topic
 12 Subscribed to this forum
Sort:
Author
Messages
theotherkidd
New Member
Posts: 0
New Member
I have a user who would like to have all fields cleared after she does a Match in Ap20.1. Currently all fields clear successfully on a custom AP20.1 except for the Vendor field. I tried various JAVA scripts all to no avail. Anyone know of a Java script (or any other method) that can clear this field? Thanks.
John Henley
Posts: 3364
New Poster
New Poster
Congrats on posting!
Engaged Reader
Engaged Reader
You are an engaged reader!
Avid Reader
Avid Reader
Avid Reader art thou!
You should be able to do this in FORM_OnAfterTransaction() by using lawForm.setFormValue
Thanks for using the LawsonGuru.com forums!
John
theotherkidd
New Member
Posts: 0
New Member
I'm new to Lawson and Java. Can you give an example? I tried the function listed below but it doesn't work. Thanks.

function FORM_OnAfterTransaction(fc)
{
if (fc == "M")
lawForm.setFormValue("text7","");
}
John Henley
Posts: 3364
New Poster
New Poster
Congrats on posting!
Engaged Reader
Engaged Reader
You are an engaged reader!
Avid Reader
Avid Reader
Avid Reader art thou!
Well, your first issue is that 'fc' isn't passed to FORM_OnAfterTransaction, only to FORM_OnBeforeTransaction.

Here's a sample from the Lawson documentation:
function FORM_OnAfterTransaction(data)
{
// was the transaction successful?
if (formState.agsError) return;

// following an add transaction, clear the "_f2" field
var fc=data.getElementsByTagName("_f1");
if (fc && fc.length > 0)
fc=fc[0];
if (fc == "A")
lawForm.setDataValue("GL-COMPANY","");
}
Thanks for using the LawsonGuru.com forums!
John
theotherkidd
New Member
Posts: 0
New Member
Thanks John,
I'll give it a try.
theotherkidd
New Member
Posts: 0
New Member
I get an error when using the data.getElementsByTagName function, so I tried the following:
function setFocus()
{
lawForm.positionInFieldById("text8");
}

function FORM_OnAfterTransaction(val)
{
if(val.selectSingleNode("//_f1").text == "M")// && lawForm.getMessageNbr() == "000")
{
lawForm.setDataValue("API-VENDOR","");
setTimeout("setFocus()", 300)
return true;
}
else
{
setTimeout("setFocus()", 300)
return true;
}
}

It works for me, but not for the user. Any ideas?
Terry P
Veteran Member
Posts: 234
Veteran Member
I have a "button" that clears part of the form, like the ctrl-shift-k shortcut. I position the cursor first because I want only the "detail lines" cleared.

The button just runs the function below. You could put it in another event though, most likely FORM_OnAfterTransaction(). If so additional code to check what action was taken or it would do it every time (which is maybe what you want anyway).

function ClearForm()
{
lawForm.positionInField("_f66r0");
tranMagic.clearFormData("_f66r0");
}
John Henley
Posts: 3364
New Poster
New Poster
Congrats on posting!
Engaged Reader
Engaged Reader
You are an engaged reader!
Avid Reader
Avid Reader
Avid Reader art thou!
Gary, I remember this happening in another instance with a client. I think it turned out that the form itself had changed (i.e. the underlying AP20.scr was different) and/or the key numbers which are used to pass the fields from form to form as well as hold the values had changed. In that case, what I had to do was re-implement the form, so that Lawson would regenerate the XML, and then re-apply my customizations.
Thanks for using the LawsonGuru.com forums!
John