Call BSFN from Javascript on Form

BOster

BOster

Legendary Poster
I have figured out how to embed Javascript inside of a Text Block control w/o any problem. Now I am trying to figure out how to do some logic, set some form control field values and call a business function using the form control fields as parameters... I am not having too much luck, I am stuck on setting the form control fields from within JS. Here is the relevant code... can someone point me in the right direction (btw this is just test code so that I can get the concepts down).

<SCRIPT LANGUAGE="JavaScript">
function setUdcVals()
{
var enterSY = document.getElementById('C21');
var enterRT = document.getElementById('C23');
var enterKY = document.getElementById('C25');
var sy = document.getElementById('C29');
var rt = document.getElementById('C31');
var ky = document.getElementById('C33');

sy.value = enterSY.value;
FCHandler.onExitVA(sy,false);

FCHandler.onTextLimit(rt,2);
rt.value = enterRT.value;
FCHandler.onExit(rt,false);

FCHandler.onTextLimit(ky,10);
ky.value = enterKY.value;
FCHandler.onExit(ky,false);
}
function getUdcDesc()
{
oc('35');
}
function getAndSetUdc()
{
setUdcVals();
getUdcDesc();
}
</SCRIPT>
<INPUT type="button" value="Set" onClick="setUdcVals()">
<INPUT type="button" value="Get" onClick="getUdcDesc()">
<INPUT type="button" value="GetAndSet" onClick="getAndSetUdc()">
 
This sounds interesting. What is it that you're using javascript for? And what was the solution that ended up working for you?
 
As a proof of concept test before I started the real work, I wanted to create a form where I enter the keys to a UDC value, have java script copy those values to JDE FC fields that it can use, envoke a BSFN to get the UDC and place those values in a JDE FC. With out going into too much details here are some of the key points and a copy of the javascript code.

1. Any FC you wish your javascript to interact with cannot be hidden or read only via the FDA. You can set these attributes with another javascript section at the end of your form, just DONT do it via the JDE toolset.

2. To call a BSFN from javascript (or run any other er code) create an unhidden button (see above) that executes the code and then in javascript run the javascript code that gets executed in the onclick event (the javascript onclick event) of the button.

3. Use FC fields as variables, if you want ER code to act on it your javascript code must set the .value of the field AND call the correct JDE javascript code to set the FC value on the server.

Code:
function setUdcVals()
{
var enterSY = document.getElementById('C21');
var enterRT = document.getElementById('C23');
var enterKY = document.getElementById('C25');
var sy = document.getElementById('C29');
var rt = document.getElementById('C31');
var ky = document.getElementById('C33');

sy.value = enterSY.value;
FCHandler.onExitVA(sy,false);

rt.value = enterRT.value;
FCHandler.onExit(rt,false);

ky.value = enterKY.value;
FCHandler.onExit(ky,false);
}
function getUdcDesc()
{
oc('35');
}
function getAndSetUdc()
{
setUdcVals();
getUdcDesc();
}
</SCRIPT>
<INPUT type="button" value="Set" onClick="setUdcVals()">
<INPUT type="button" value="Get" onClick="getUdcDesc()">
<INPUT type="button" value="GetAndSet" onClick="getAndSetUdc()">


Code to hide FC objects on form:

<SCRIPT LANGUAGE="JavaScript">
var testButton = document.getElementById('C35');
testButton.style.display='none'
</SCRIPT>
 
getElementById is probably not the best method. Those numbers will change when the form changes. The descriptive words for the fields probably won't change though.

You're better off loading the whole page and collecting the 'span' segments(via getElementsByTagName). Then you can roll through the array using indexOf to find the actual names of the fields (i.e. 'Description').
 
I looked at the generated HTML and the names were usually the name was usually just the control ID as in name="32" and the ID was usually the control ID prefixed with a 'C' as in ID="C32". Granted when you mess with the controls in FDA you are probably going to have to mess with the embedded JavaScript, but.... seems to be working.


<<<< check that >>>>>
Re-read your post... misunderstood it the first time... I will have to look into trying that instead...
 
Hi Boster,

I want to write a while loop and click the JDE button every 10 seconds. with the help of your post, I added few code and button click is working if there is no while loop. Inside while loop the button click is not working. am I doing anything wrong? kindly advise. As of now, i dint write logic for wait.

<SCRIPT LANGUAGE="JavaScript" type="text/javascript">

function bclick()
{
var sy = document.getElementById('C0_28');
var valy = "Y";
oc('', '0_30');
document.getElementById('C0_28').value="X";
alert("You entered: " + sy.value);
while (sy.value==valy)
{
oc('', '0_30');
alert("You entered: " + sy.value);
}
}

</SCRIPT>

<INPUT type="button" value="Set" onClick="bclick()">

=======================================================================
CONTROL: BUTTON PUSH (ID = 0_30)
EVENT: Button Clicked
-----------------------------------------------------------------------
OPT: Using Defaults
0001 //
0002 VA frm_LineNumber = "5"
0003 FC Math Numeric = [FC Math Numeric]+1
0004 If FC Math Numeric is equal to VA frm_LineNumber
0005 FC Journaling Flag (ID=0_28) = "Y"
0006 End If

Thanks
Imran
JDE 9.1
 
It has been a long time since I have messed with embedded Javascript. A timer type control like what I think you are trying to implement is probably the most common use case. There are other threads about this and others that are more knowledgeable than myself. If you can find it there is one thread where I believe Darren Ricciardi (WhippingBoy) lists out some of the things to consider before you implement something like this. You have to be very careful in how this is done because there are limitations and there could be some unexpected side effects not to mention the fact this is starting to get into that grey area of "supported" custom development. In other words, I am sure Oracle really didn't intend or envision that we would embed JS in our APPLs so a future tools release may break any solution that relies on it.
 
HI Brain,

Looking for help on reading the JDE grid cell values thru JavaScript. You have done a great work related to this and I am referring to this thread. Your inputs will be of great help.

Thanks
 
Back
Top