Results 1 to 9 of 9

Thread: Call BSFN from Javascript on Form

  1. #1
    Senior Member
    Join Date
    Mar 2004
    Location
    Fort Worth, Texas
    Posts
    1,552

    Call BSFN from Javascript on Form

    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()">

    Brian Oster
    Application Development Manager
    E1: 9.0 (TR9.1.5.1) / 9.2 (TR9.2.2.2)
    JAS/BSSV: Weblogic 12.1.2 / Weblogic 12.2
    ES: Win2008 / Win2016
    DB: MSSQL 2014 / 2016
    WebDev Client: Win7Pro / Win10Pro

  2. #2
    Senior Member
    Join Date
    Mar 2004
    Location
    Fort Worth, Texas
    Posts
    1,552

    Re: Call BSFN from Javascript on Form

    Never mind, I finally got it working.
    Brian Oster
    Application Development Manager
    E1: 9.0 (TR9.1.5.1) / 9.2 (TR9.2.2.2)
    JAS/BSSV: Weblogic 12.1.2 / Weblogic 12.2
    ES: Win2008 / Win2016
    DB: MSSQL 2014 / 2016
    WebDev Client: Win7Pro / Win10Pro

  3. #3

    Re: Call BSFN from Javascript on Form

    This sounds interesting. What is it that you're using javascript for? And what was the solution that ended up working for you?
    E1 8.11 SP1 8.97
    Windows 2003
    MS SQL2005

  4. #4
    Senior Member
    Join Date
    Mar 2004
    Location
    Fort Worth, Texas
    Posts
    1,552

    Re: Call BSFN from Javascript on Form

    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>
    Brian Oster
    Application Development Manager
    E1: 9.0 (TR9.1.5.1) / 9.2 (TR9.2.2.2)
    JAS/BSSV: Weblogic 12.1.2 / Weblogic 12.2
    ES: Win2008 / Win2016
    DB: MSSQL 2014 / 2016
    WebDev Client: Win7Pro / Win10Pro

  5. #5
    Senior Member WhippingBoy's Avatar
    Join Date
    Jun 2001
    Location
    Colorado, USA
    Posts
    708

    Re: Call BSFN from Javascript on Form

    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').
    Darren Ricciardi - E-One Whipping Boy
    Senior Director, Technologies
    Advanced Logistics Consulting
    Instructor, Oracle University


  6. #6
    Senior Member
    Join Date
    Mar 2004
    Location
    Fort Worth, Texas
    Posts
    1,552

    Re: Call BSFN from Javascript on Form

    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...
    Brian Oster
    Application Development Manager
    E1: 9.0 (TR9.1.5.1) / 9.2 (TR9.2.2.2)
    JAS/BSSV: Weblogic 12.1.2 / Weblogic 12.2
    ES: Win2008 / Win2016
    DB: MSSQL 2014 / 2016
    WebDev Client: Win7Pro / Win10Pro

  7. #7
    New Member
    Join Date
    Jun 2005
    Location
    India
    Posts
    29
    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

  8. #8
    Senior Member
    Join Date
    Mar 2004
    Location
    Fort Worth, Texas
    Posts
    1,552
    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.
    Brian Oster
    Application Development Manager
    E1: 9.0 (TR9.1.5.1) / 9.2 (TR9.2.2.2)
    JAS/BSSV: Weblogic 12.1.2 / Weblogic 12.2
    ES: Win2008 / Win2016
    DB: MSSQL 2014 / 2016
    WebDev Client: Win7Pro / Win10Pro

  9. #9
    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
The legal restrictions and terms of use applicable to this site are available here.
Use of this site signifies your agreement to the terms of use.
JDELIST is NOT affiliated with JD Edwards® & Company, Oracle or Peoplesoft. Contents of this site are neither endorsed nor approved by JD Edwards® & Company and, or Oracle.