Advanced Script - Start Process 2
Advanced Script - Start Process 2
Hi All,
I've been going round in circles for a while now and cant work this one out..have searched the forum, looked in user guide and programmer's ref but cant work it out!
I'm trying to get a process to run when a form is displayed. The process requires the same business object that is being displayed to be passed in as context. I can't work out how to pass the business object in as context (how do I get the object ID into the parameters of the function)?
This is the script placed in the init script of the business object form
AwareApp.startProcess2('NameOfMyProcess','BusinessObjectName',NEED_TO_GET_OBJECT_ID_HERE,'main')
Anyone know how I might achieve this?
Thanks
I've been going round in circles for a while now and cant work this one out..have searched the forum, looked in user guide and programmer's ref but cant work it out!
I'm trying to get a process to run when a form is displayed. The process requires the same business object that is being displayed to be passed in as context. I can't work out how to pass the business object in as context (how do I get the object ID into the parameters of the function)?
This is the script placed in the init script of the business object form
AwareApp.startProcess2('NameOfMyProcess','BusinessObjectName',NEED_TO_GET_OBJECT_ID_HERE,'main')
Anyone know how I might achieve this?
Thanks
Re: Advanced Script - Start Process 2
Maybe I am not understanding what you are trying to accomplish, but why not have a process find the record you want, call your special process then display the form
i.e.
FIND BO WHERE ....
YourSpecialProcess
VIEW BO using YourForm
bruce
i.e.
FIND BO WHERE ....
YourSpecialProcess
VIEW BO using YourForm
bruce
Re: Advanced Script - Start Process 2
I could do as you suggest and this is my plan b. The trouble with plan b is that makes for a lot of work. The editing form for this particular business object is called form lots and lots of different places all over my application. To do as you suggest would mean running the ‘load my form’ process in lots of places. If I can get my ‘special process’ to work in the script of the form it’s just one change to make in the config tool.
Thanks for considering this for me though
Thanks for considering this for me though
Re: Advanced Script - Start Process 2
I think it's just:
AwareApp.startProcess2('NameOfMyProcess','BusinessObjectName',{ID},'main')
It identifies ID for context in queries, haven't tested it in objects
AwareApp.startProcess2('NameOfMyProcess','BusinessObjectName',{ID},'main')
It identifies ID for context in queries, haven't tested it in objects
Re: Advanced Script - Start Process 2
Another solution if the curly tag one doesn't work is hardcoding the id hidden e.g in the form header and then use JS to find the id, assign it to a JS variable which you then use in your aware function. This assumes the JS to get ID and run aware function is a render script.
Henrik (V8 Developer Ed. - Windows)
-
- Posts: 7565
- Joined: Sun Apr 24, 2005 12:36 am
- Contact:
Re: Advanced Script - Start Process 2
Starting a process when a form is displayed is not a good idea generally (depending on what the process is doing it may or may not work)
Why do you need to run a process? What does this process do?
Why do you need to run a process? What does this process do?
Aware IM Support Team
Re: Advanced Script - Start Process 2
Thanks Rennur but that didn’t work, my gut tells me it should be that simple but is the syntax is off just a little.....?
Henrik, your idea sounds good but my JS knowledge doesn’t stretch that far! Any idea where I could find an example of something similar?
Thanks both
Henrik, your idea sounds good but my JS knowledge doesn’t stretch that far! Any idea where I could find an example of something similar?
Thanks both
Re: Advanced Script - Start Process 2
Hi Support,
The idea is that when the form is displayed a process is run that compares the data held in AwareIM with the data held in Xero. If the data in AwareIM is out of date then a REST call is made to update the data as the form is displayed.
More often than not the data held in AwareIM would most likely be up to date as a scheduled process is run at night to check if any changes were made in Xero. However, a nightly process doesn’t guarantee the data isn’t out of date.
It’s easy to push changes made in AwareIM to Xero but a bit more challenging to get changes that were made in Xero. Webhooks would solve this issue but I don’t think AwareIM supports them.
Thanks
The idea is that when the form is displayed a process is run that compares the data held in AwareIM with the data held in Xero. If the data in AwareIM is out of date then a REST call is made to update the data as the form is displayed.
More often than not the data held in AwareIM would most likely be up to date as a scheduled process is run at night to check if any changes were made in Xero. However, a nightly process doesn’t guarantee the data isn’t out of date.
It’s easy to push changes made in AwareIM to Xero but a bit more challenging to get changes that were made in Xero. Webhooks would solve this issue but I don’t think AwareIM supports them.
Thanks
-
- Posts: 7565
- Joined: Sun Apr 24, 2005 12:36 am
- Contact:
Re: Advanced Script - Start Process 2
You shouldn't do it with Javascript - it won't work. Plan B that Bruce suggested is the only option.
I also think that syncing data automatically is not a good idea either (especially doing it before the form is displayed). I would probably provide a separate button that would explicitly sync the data, so that the user knows what's going on.
I also think that syncing data automatically is not a good idea either (especially doing it before the form is displayed). I would probably provide a separate button that would explicitly sync the data, so that the user knows what's going on.
Aware IM Support Team
-
- Posts: 7565
- Joined: Sun Apr 24, 2005 12:36 am
- Contact:
Re: Advanced Script - Start Process 2
Also, Aware IM does support web hooks, which is just callback URL's. All you need to is define Aware IM services that will handle calls from Xero. Each service will be automatically exposed on a particular URL that you need to provide as a web hook.
Aware IM Support Team
Re: Advanced Script - Start Process 2
Well, I do concur with support that doing this might not be the best way and I would personally also do something like Bruce´s suggestion (or better yet the webhook idea) but IF you want to try what I suggested, here are the general things (scribbled down so not thoroughly tested etc.):Gabbitas wrote: ↑Mon Nov 09, 2020 12:03 am Thanks Rennur but that didn’t work, my gut tells me it should be that simple but is the syntax is off just a little.....?
Henrik, your idea sounds good but my JS knowledge doesn’t stretch that far! Any idea where I could find an example of something similar?
Thanks both
1. Create a hidden div with the ID in the form header: <div id="myhiddeniddiv" style="display:none"><<Object.ID>></div>
2. Use JS to find the div and assign value to variable: var objectidvalue=$("#myhiddeniddiv").text();
Source: https://api.jquery.com/text/
3. Use the variable in the aware function: AwareApp.startProcess2('NameOfMyProcess','BusinessObjectName',objectidvalue,'main')
Henrik (V8 Developer Ed. - Windows)