Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Adding sub-scripts

Featured Replies

I am experiencing problems with adding sub-scripts to a "main" script(1). My main script already has a subscript(2) within it. This all works fine.

I have another script(3) that also works fine on its own. I have tried to incorporate this third script into my "main" script (1).

However, the script(3) does not work correctly once it is added as a sub script to the "main" script(1).

Is there certain steps/criteria I should be adding into my scripts to ensure sub scripts work correctly?

Hi Ben,

Not enough information ... Can you post your scripts or a demo file showing what doesn't work for you?

  • Author

Hi LaRetta,

I have posted the script as a scan. I hope this helps. Basically, I have almost got it working, all steps work apart from the last op (perform script ["update stock qty 2"] This script does not function at all. The script itself works, but only if its assigned to a button on its own.

Thanks..

Picture1.jpg

That last script should work fine ... except ...

Scripts fire depending upon the layout they are on at the time. In that last script, do you have a layout switch to the proper table occurrence? If it fires from a button, it must be on the same table occurrence as the one the button is on. Otherwise, it's firing on the wrong TO and won't work.

Also, do you have a script parameter attached to that button?

  • Author

Thankyou for your time...

In that last script, do you have a layout switch to the proper table occurrence? Ans. No I don't. I am not sure I know what you mean by a layout switch?

How do I tell which table occurance the script is firing off? As I say, the scripts work independant from the same layout, in the same portal window. (FYI. The script button is located on a portal row within a portal window. Not sure if this is a contributing factor?

Also, do you have a script parameter attached to that button? Yes, I had, a script parameter which is now redundant. I have now removed it.

"FYI. The script button is located on a portal row within a portal window. Not sure if this is a contributing factor?"

Yep. Can you post that last sub-script for us? Because, how can a script (fired based upon the existing layout) know which row (related record) it's supposed to work on?

"How do I tell which table occurance the script is firing off? "

Scripts always fire based upon the table occurrence they are on. You would tell by going to Layout mode, then Layout Setup and seeing which TO is listed in the popup. Since the script bases itself on the main layout, it's not firing on the portal records. We need to see that script ... Is that script parameter really redundant? That parameter probably pointed to the related record to act upon, no?

Edited by Guest

Okay, that last sub-script "Update Stock Quantity" ... on a related record? That's your problem.

Which related record should it be setting? It's probably setting the first one ...

  • Author

Yes, of course. I have posted the script for you too see. I te does include a related record function. Probably does'nt help either??

Would I just be better off including the whole sub script into the main one?? Then it would know? No?

Also, yes, I believe the script parameter, I was, using, is redundant as I was calling it up for something else intially. Not related to my problem. FYI

Picture2.jpg

Edited by Guest

As you can see, that first Set Field [] can't act. It doesn't know the portal row number because you're not in a portal when you set your global. That script parameter which you thought was redundant ... isn't. :wink2:

UPDATE after your update ... well no - just including the sub-script in the main won't help. The problem is isolating the specific related record you want to work on. But I don't understand your process here. Why do you need the portal number at all? I think there are much easier ways to accomplish what you're trying to do. Can you post a sample file? I see no need to jump around like you're doing. And I wouldn't use copy/paste either...

Edited by Guest

  • Author

So, if I create a script parameter, and assign to the button in question. As per how I had it.

How do I get the sub script to pick the same parameter? It did'nt recognise before. I will have to have another play I think. Sorry if I am not getting it quite. Thanks for your time..

I suggest you post a sample of this scripting process. Once we see the process in action, we'll be able to help further.

Simply, you can't 'pick up' a script parameter from a button only via script ... a User must press the button. Script parameters can be passed to the sub-script after a button press. I'm suggesting you re-think what you're doing here. There are certainly easier ways.

And there are many people here willing to help you. I have to leave. Hopefully others will help you through this. If not, I'll check in when I get home late tonight. :wink2:

LaRetta

  • Author

Hi LaRetta, I have since been trawling through ideas, trying to apply some of your theory. I have made it work, however. I am not so sure it is the easiest way. I have incorporated it all into one script. I have also removed the need for copy and pasting. Yes, not good for this application, or any infact.

Please view the script attached. If there is an easier way then I would love to know what it is. The flavour i've been chewing does'nt taste so good after 5 hours or so. If you know what I mean.

Thanks for your advice. It has helped tremendously. Still to be improved I am sure.

Regards,

Ben

Picture3.jpg

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.