on 10-31-2014 9:12 AM
Hello,
I'm trying to launch an URL in EventHandler on click of a Link UI element. I tried using OpenLink operation in EventHandler and it works fine if I enter hardcoded URL. But I would like to have dynamic URL based on the system. I've even tried writing code in AfterModify to generate dynamic URL and bind with the Data field in screen and bind that in operation. It does not work. The value comes as blank as I believe the AfterModify only triggers when there is any Changes in the screen.
I tried using Operation 'Script' to open url by giving the script code as shown below
$controller.OpenLink('https://www.sap.com')
When I use above controller method, even static URL also does not work when I click on the Link.
I've attached the screenshot. Could you please help me which approach can I follow to use dynamic URL launch?
Thanks.
Regards,
Mohan Babu
Hi Mohan,
in my opinion, your code should work.
e.g. the following script code works fine for me:
url = "http://maps.google.com/maps?q=" + latitude + "," + longitude
$controller.OpenLink(url)
Please check whether you have set the correct event handler in the OnClick Event of the link control.
Best regards,
Ludger
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Ludger,
I've set correct event handler as I've only one event handler in the controller. However, I heard if we have scripts in event handler it will not be compatible with ipad devices.
I've generated dynamic url in AfterModify event and bound to the extension BO element. But when I execute the QC of opportunity, it does not work. Will AfterModify gets call each time when the screen loads?
Thanks.
Regards,
Mohan Babu
Hi Mohan,
Yes, Event Handler and lots of other magic sadly do not work as assumed on mobile devices.
I assumed you were talking about desktop screens since you did not mention "mobile".
No, AfterModify will not get called each time when the screen loads.
However, why do you need the computation each time on loading?
Usually it suffices to compute field content only once after modification.
If your computation produces a different result if performed later again then you should check your dependencies. If you have a dependency on a second object you might also like to trigger computation in the AfterModify of the other BO.
Best regards,
Ludger
This means using the OpenLink Action instead of scripting should work.
But Horst:
There is a lot of other stuff working differently.
Furthermore this highly depends on whether you are on iPad, iPhone or Android player - each player has different things working (or not working) as expected.
E.g. Buttons, the visibility property, the enabled property, possibly also the readonly property.
As a developer I have to check myself what is actually working and what is not.
This causes a lot of development overhead so we decided to only provide those screens as mobile that are absolutely necessary to be mobile.
This is really sad because we'd love to have a lot more of our stuff at least also to be available for tablet screens.
But this is actually a different discussion.
Best regards,
Ludger
Hello Ludger / Horst,
Thank you for your inputs. In which case, can you please tell me whether can I use custom BO actions to get the URL dynamically and have the BOAction operation in event handler?
Which are all the operations should I use for this approach? How can I create instance of custom BO in event handler?
Thanks.
Regards,
Mohan Babu
Hello Vinod,
I've tried the same as you had mentioned. I will tell you the steps which I've followed.
1. Created extenstion field <URL> as WebURI in Extension BO
2. In AfterModify, I've generated the URL and assigning to the BO element as shown below
this.<URL> = myLinktoPDF;
3. Bound this <URL> field in the Data Model by dragging from the BO to Data Field.
4. Bounded the DataField to OpenLink operation.
When I check in the debug, the field <URL> gets the URL in AfterModify. But when I click on the link, it is opening blank page. I believe the value is not getting passed to Data Field. I've even tried adding a text field in the screen to view this value. It is empty.
I do not know what I'm missing here.
Thanks.
Regards,
Mohan Babu
Hi Mohan,
First thing is aftermodify does not get triggered unless you change your BO. So in the initial load it will not work.
My suggestion is to have transient variables and fill then with an action when even you need it.
If you are working on IPad then tough it looks strange below is what you have to do.
you need to add this URL field in a 0:n node and then configure your action to the pick the URL from Table and then it should work.
Which means you define a Advanced List Pane and mark the column to be of type Link
In the OnClick define the event EV_OpenLink and in the event configure as below
If it still does not work I suggest you to raise an incident.
Regards
Vinod
User | Count |
---|---|
89 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.