- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2018 03:02 PM
Hey everyone,
I have created a cloned version of the link-button widget, which uses the following code to perform a simple operation of opening a new window, and passing parameters through the URL in order to populate the new record:
HTML Template:
<a href="?id=form&table=incident&sys_id=-1&view=mobile&query=parent_incident={{data.sys_id}}" class="btn btn-default" target="_blank">{{data.buttonMsg}}</a>
Server Code:
data.buttonMsg = gs.getMessage("Create New Incident");
data.sys_id = $sp.getParameter('sys_id');
I have embedded this widget within a cloned version of the OOB Form widget, so that the button displays near the bottom, similarly to how UI Actions would, as seen below:
My requirement, is that I want this embedded widget to be hidden if the record currently loaded into the form widget is a new record, and only display if the record that is loaded in to the form has been previously inserted into the database. I've tried a couple of options and ways, such as editing the HTML/Server Code of the cloned Form widget to include something like this:
HTML Snippet
<widget id='link-button2' ng-hide="data.hideButton"></widget>
Server Code Snippet
data.hideEmbeddedButton = false;
data.checkForNewRecord = $sp.getParameter('sys_id');
if(data.checkForNewRecord == -1) {
data.hideEmbeddedButton = true;
}
As is, nothing has seemed to work, and my skills in AngularJS and widget scripting are still new enough that I may be missing something. Anybody have any suggestions?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2018 04:34 PM
I believe ng-hide won't work directly on the sp-widget directive. You are using the sp-widget directive right?
You can wrap it in a span like this below (you shouldn't actually need to do anything in your form widget server script except you do need to get an instance of your custom link widget):
<span ng-hide="data.sys_id=='-1'">
<sp-widget widget="data.yourNewWidget"></sp-widget>
</span>
you can get the instance of your link widget in the server script like this:
data.yourNewWidget = $sp.getWidget('your-new-widget-id');

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2018 04:34 PM
I believe ng-hide won't work directly on the sp-widget directive. You are using the sp-widget directive right?
You can wrap it in a span like this below (you shouldn't actually need to do anything in your form widget server script except you do need to get an instance of your custom link widget):
<span ng-hide="data.sys_id=='-1'">
<sp-widget widget="data.yourNewWidget"></sp-widget>
</span>
you can get the instance of your link widget in the server script like this:
data.yourNewWidget = $sp.getWidget('your-new-widget-id');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2018 09:48 AM
Hey Jon,
Thank you for your advice! This ended up working splendidly for what I needed. I had previously tried wrapping my HTML snippet in a span tag, but it didn't seem to work then either. The main thing that ended up helping, was changing from using the HTML version of embedding a widget, with the <widget></widget> tags, and instead doing the <sp-widget></sp-widget> tags with the server code being what pulls in my custom widget.
Much appreciated!