How to call a function from an OnLoad Client Script from an Onsubmit client script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2023 11:03 AM
I need to be able to update the value of a field in an OnLoad Client Script. I am calling the function that updates the field from an OnSubmit Client Script but I am not sure that I am calling the function correctly. I leave the code that I am using:
Catalog Client Script OnSubmit:
function onSubmit() {
var totalCost = 10;
updateGrandTotal(totalCost);
}
Catalog Client Script OnLoad:
function updateGrandTotal(totalCost) {
g_form.setValue('grand_total', totalCost);
}
function onLoad() {
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2023 11:12 AM
You would not call another client script, you would put the code you need directly in the onSubmit client script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2023 11:16 AM
Hello Kristen, thank you for your answer. Yes, I know I can do that but in this case for X reason I need to call a OnLoad Client script, I am not allowed to put the code in the same client script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2023 11:37 AM
Is this a company policy? If so, then what is the business rule you are trying to build these two client scripts for? There might be another way to accomplish this ask.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2023 11:21 AM
Hi Rico , I am not sure what your use case here is , but the approach is incorrect , if you can tell your exact need i can suggest you alternate solution but you can't call a function this way.