Skip to Content
avatar image
Former Member

Control not found error with Personas 2.0

Hi all

I am trying to create a script which will auto-populate the Validity End field in txn ME21N.  But each time I get an error saying that the Control does not exist... why?

Am I missing something?

The screen looks as follows:

The script is as follows:

The script works as follows:

  1. Copy the value in the 'days' field (marked 1)
  2. Refresh the screen (don't ask me why but if I put this step 1st the JavaScript does not work!)
  3. Add this to the existing date
  4. Paste the date as determined in (2) into field marked (3) - this is just a check to make sure the Javascript works and will be removed
  5. If the Validity End control exists...
  6. Paste the date as determined in (2) into Vaility End field
  7. If the Validity End control does not exist...
  8. Return error in field marked (7)

Thanks for your help!

Gareth

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Dec 31, 2014 at 10:44 AM

    Thanks all for your help.

    For some reason the original script simply started working - it recognised the control and pasted the values in.

    Now, after some playing - and using the suggestions above - I have a working script that sets the validity period based on a drop-down selected by the user.

    The screen looks as follows:

    The user selects the appropriate validity period from the drop-down and clicks the button.  The following script runs:

    The steps are (simple enough):

    1. Copy the number of months from the drop-down
    2. Run the Javascript to convert the current date (from_date) and the calculated end date (to_date) into a string in the format dd.mm.yyyy
    3. Paste the value into Validity Start field
    4. Paste the value into Validity End field

    The Javascript is as follows:

    var d1 = new Date();

    var d2 = new Date();

    var day = d2.getDate();

    if  (day >= 29) {

        d2.setDate(1);

      d2.setMonth(d2.getMonth() + parseInt(args.months) + 1);

      d2.setDate(d2.getDate() - 1);

    } else {

      d2.setMonth(d2.getMonth() + parseInt(args.months));

    }

    args.from_date = ("0" + (d1.getDate())).slice(-2) + "." + ("0" + (d1.getMonth() + 1)).slice(-2) + "." + d1.getFullYear();

    args.to_date = ("0" + (d2.getDate())).slice(-2) + "." + ("0" + (d2.getMonth() + 1)).slice(-2) + "." + d2.getFullYear();

    The script works as follows:

    1. If the current date is the 29th or greater it goes to the first day in x+1 months and then goes one day back - to get to the last day of the month in x months' time.**
    2. If not it adds x months to the current month.

    ** This step is required to handle short months (less than 31 days).

    Here's hoping it keeps working!

    Regards

    Gareth


    Add comment
    10|10000 characters needed characters exceeded

  • Dec 23, 2014 at 10:31 PM

    Hi Lynch,

    Just noticed few things:

    * you don't need refreshscreen at step 2.

    * paste value should use d instead of date

    Also can you explain what tabs you have cached?

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Chinthan

      Thanks for the response!

      1. I have tried with and without the Refresh step.  Neither works!  If I remove the refresh at step 2 I get the error 'Control not found' error.  If I add it in, the script populates field (7) with "Field not found" as per the If statement.
      2. I'm not sure what you mean by "paste value should use d instead of date".  The script is pasting the 'date' variable that is determined by the JavaScript.

      The picture below shows which tabs are cached:

      Thanks

      Gareth

  • avatar image
    Former Member
    Dec 27, 2014 at 08:22 AM

    can you post the whole code  of step 3.

    also can you disable the tab caching and try as all the information is available on the same tab.

    you definitely do not refresh screen. It seems, refresh screen is loosing the focus to the active tab, so the control is not found error is coming. But not exactly sure why it is going to 7 and 8 when you take that off.  

    Add comment
    10|10000 characters needed characters exceeded