Hide 'Save' button on asset form - servicenow

In OOB asset form save button is not there, but it is present in my instance.I want to hide this save button.As you can see there are many UI actions, how I can determine which one works an asset table?(all ui actions are on global table)
Please help me out....

As you have correctly pointed out, there are 4 global UI Actions with the name "Save". They all have different combinations of the true/false fields: "Form Button", "Form Context Menu", and "Show Insert".
You want to de-activate the one that has "Form Button" value of "True" and "Show Insert" value "true".
The only reason it is being displayed is because of the condition isAdvancedUI() is returning as true. This is because the system property 'glide.ui.advanced' has been set to true. By setting this to true, a number of useful options in the context menus, become visible as form buttons (Save, Insert, Insert and Stay). Unfortunately one of the save buttons that appears, is not very desirable, because there is already a "submit" for inserting new records.
This is why it is perfectly OK to disable this button globally.

Gordon's answer here (https://community.servicenow.com/thread/261454) is exactly what you're looking for. Identify and override the save buttons (ones with "form button" checked) and you'll be good to go.
Side note: Generally it's a good idea to avoid changing the out-of-box UI actions, especially for something simple like hiding the button. Using a method like adding a condition can result in you 'owning' the button and make upgrades more time consuming. That said, there is a mechanism called 'UI Action Visiblity' that can control visibility for views without modifying (and owning) the UI Action itself. I've used this in the past and it works well.
https://docs.servicenow.com/bundle/istanbul-servicenow-platform/page/administer/list-administration/concept/c_ControllingVisibilityWithRoles.html

You can accomplish this with a Client Script. Keep in mind that hiding the button is obfuscating the Save button rather than restricting the access.
I tested this on a personal instance and it worked.
Name: Hide save button
Table: Asset [alm_asset]
UI Type: Both
Type: onLoad
Active: Checked
Inherited: Checked
Global: Checked
Script
function onLoad() {
var items = $$('BUTTON').each(function(item){
if(item.innerHTML.indexOf('Save') > -1){
item.hide();
}
});
}
This will load when any form view loads that extends the Asset [alm_asset] table because the Inherited box is checked. This is important because you can have hardware assets, license assets, and so on.
When this runs, it will search each button for Save and then hide it if matched.

Related

MAUI Show/Hide controls based on mode New/Edit/View

I need an idea, please. I have a Details form which shows the fields of a model (about 10 fields in all). There are three modes in which I could show this view - in mode "Edit", in mode "New" (which, of course, is like an edit but without values), and in mode "View" (no changes allowed, just labels).
I could of course create three Details pages, one for each mode, and call them selectively, but I would like to have just one and pass the "DocumentMode" parameter to it. That View should bind to that mode and selectively show/hide controls, probably like "DocumentMode = VIEW => Show labels" or "DocumentMode = EDIT => Show Entry or Editor, show DatePicker, TimePicker, etc".
My question is this: How do I show/hide these groups of controls depending on the DocumentMode parameter ? Which would be the best way to do this ? I could probably bind the "IsVisible" property to my documentMode parameter, but I think that is a really ugly solution (and I assume that regardless of whether the controls are used or not in a specific mode, they will all be loaded anyway).
Thank you.
Alex
I think you can use a Listview or Collectionview to represent your data because you mentioned that you have 10 fields.
In addition, you said you need a "new" button, so you can set it at the top of the app as a button, when you click the button then you jump to another page which is blank and you can add the data.
This must refer to the shell you may need to set a navigation.
Then the "view" and the "edit" you can use the property SelectionChanged to control the item, I mean when you click the item in collectionview, the SelectionChanged method can be triggered and turn to another page which can show the detail about the item you clicked. In the page you can view and edit the data.
Here are some articles you might be able to use: Listview, Collectionview, Shell
If you have more information to add, please kindly share with me.

How to use button to display filtered data from excel table in PowerApps?

I am a newbie in PowerApps, and I am trying to build an app where based on user click, user should be able to see filtered data.My test data looks like below.For this I have created 3 button in my gallery titled as "Available", "Out-of-service" and "In-use". So, let's say when user clicks on "Available" button, the app should display the user "Sys1" and "Sys2". Likewise, same is true for "Out-of-service" and "In-use" button. I have my datasource save as ExcelTable in Onedrive and I was able to successfully connect to the source.However, when I tried below code on my "Available" button nothing happened.I am not sure what is the issue ? [SEE BELOW UPDATE]
If there is good tutorial available for this task feel free to attached link with your response.
Code
Filter(Table1,Column2,"Available" in Column2)
Note: Property: OnSelect
Update:
After little bit of research I found that I need to have separate screen to display my filtered data. So I used Navigate() function to take me to new screen. On my screen2 I have below code
Code:
Filter(Table1, column2="Available")
Note: Property is set to "OnVisible". I also added FormViewer using Forms-> Display option. Then under Properties tab,I added column names using Edit fields.
Still Issue is not resolved!
It sounds like you have the Filter command in the wrong place. It should be in the "Items" property for the table, not in the Buttons' or in the Screen's properties. The Buttons should toggle a variable to the different Statuses you have.
The Items property of the table/gallery/etc that shows the data would look like this:
Filter(Table1, Column2=currentStatus)
The buttons would all have code that looks like this but with different statuses:
Set(currentStatus, "Available")
That way when you click the buttons, the value of currentStatus changes and will change the action of the filter.
Also, you can have the data visible on the second screen if you want but it's not strictly necessary. You can do what I described on a single screen.

Angular Material md-select load options in async way

I need to load select's options asynchronously (
through a service), using the Angular Material md-select component.
Actually, I use a click event to load data. It works but I need to click the select twice to show the options. That it's a problem.
The expected behavior is shown at this link (AngularJs Material)
The actual behavior is shown at this link.
Is Async options' loading supported by md-select?
The reason you need to click twice is because when you first click, there are no options in the select control and so it doesn't try and open the panel. Then your async method loads the options into the DOM and on the next click it will open.
In order to deal with this, you must always include at least one <mat-option> in your <mat-select>. You can add a disabled <mat-option> with a <mat-spinner> showing that the data is loading for example.
Here the most simple example of that. This is not the best approach... see below.
However, this still uses the click event which isn't the best approach. If you put the click event on the <mat-select> there are spots where you can click on the control but your click event wont trigger even though the dropdown panel still opens (places like the floating label area). You could put the click event on the <mat-form-field> but then there will be places where you can click and trigger the click event but the dropdown panel wont open (places like the hint/error text area). In both cases you lose keyboard support.
I would suggest using the <mat-select> openChanged event instead of a click event. This has its own quirks too but they are manageable.
Here is an example using the openChanged event. I also made the component more robust overall.
I also made a version that uses the placeholder element to show the spinner instead of using a disabled mat-option. This required View Encapsulation to be turned off.
Note: In my example, the service can return different data depending on the circumstances. To simulate this my fake service keeps track of how many requests you send it and changes the options returned accordingly. So I have to set the option list back to empty and clear the formControl's value every time the list is opened. I save the selected value before clearing the formControl so that if the service returns a list with the same item I can automatically reselect the value. If you only need to load the options once, then you would want to modify the code a bit to only load the options the first time the user opens the select.

How to Asynchronously Show a Create New Button On a CRM Sub Grid?

I need to hide the "Add New" button on a sub grid until certain criteria are met. Calling Xrm.Page.ui.refreshRibbon will trigger my JS function defined in my Enable Rule, but I can't get the + button to show up.
Is this unsupported, or is there some methodology to get this to work?
Seems like you have to do few extra trick.
Refreshing the subgrid command bar
You will find that when the form is loaded, if there is a value in the attribute you have referenced in your enable rule, the Add New button will be visible. If however the value changes, the sub-grid command bar will not automatically refresh to reflect the new state. Upon adding or deleting rows in the sub-grid the command bar is refresh – but this isn’t much use in this case.
The main form command bar can be refreshed using Xrm.Page.ui.refreshRibbon() however this will not refresh sub-grid command bars. Instead, we can add an onchange event to the fields that are used in our VaueRule and call:
Xrm.Page.data.save();
This will refresh the sub-grids and re-evaluate any of the EnableRules however it will also save any other dirty attributes and so should be used with caution if you do not have auto-save enabled.
Ref: https://ribbonworkbench.uservoice.com/knowledgebase/articles/489288-show-or-hide-the-add-new-button-on-form-sub-grid
Arun Vinoth did find a great article to describe the issue, but actually I've found that just calling refresh on the grid itself was all that was actually required.
It's important to note, that this does not re-run the enable rules, just shows the button if the state has changed.

Get value from autocomplete text field in ApEx

I want to create a dynamic action, that will set a value to an item on the page, when the value of another item (autocomplete text field) is set.
So the proccess goes like this:
Click on the autocomplete field
type some letters
choose one of the suggested values
I cannot find an event that will be executed when the selection of one of the suggested values happens. This way, I cannot see how I can read the value of the autocomplete field, once a suggested value is selected.
The change event doesn't fit my needs, it doesn't execute when one suggested value is selected.
I had the same problem, found this link: https://community.oracle.com/thread/2130716?tstart=0 and modified my dynamic action as follows to get the desired behaviour:
Event = Custom
Custom Event = result
From the link:
the problem seems to be the default behavior of the browser. When you
enter some text into the autocomplete and the list is displayed, the
focus is still in the text field. Also if you use the keyboard cursors
to pick an entry the focus will still be in the textfield. That's why
the change event of the textfield doesn't fire. It only fires if you
leave the field.
On the other side if you pick an entry with the mouse, the browser
will remove the focus from the text field for a moment (before the
JavaScript code puts the focus back), because you clicked outside of
the field. But that's enough so that the browser fires the change
event.
I had a look into documentation of the underlaying jQuery Autocomplete
widget
(http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/) and
there is actually an event called "result" which can be captures if an
entry is selected from the drop down list.
Try "Lose Focus" as event. It will trigger your dynamic action when you leave the autocomplete field, i.e. your curosr is moved to another field.
This probably depends on the APEX version you are using.
In case of 18.2, because the underlying component is based on Oracle JET's "inputSearch" component, you need to use following configure to capture the select change event for text with autocomplete:
event: Custom
custom event: ojupdate
Reference:
https://docs.oracle.com/cd/E87657_01/jet/reference-jet/oj.ojInputSearch.html#event:optionChange
I turned on the browser console, then turned ApEx Developer toolbar debug, and found that, on the contrary, the "Change" event does fire upon user clicking with the mouse on one of the selections. However if the user uses keyboard (type a few letters to narrow the list down, then use down arrow key to arrive at desired value, then press enter) then the Change event does not fire, just as you say.
Moreover: even when you do get the value sent back via mouse-click initiated Change event, the value isn't the autocomplete's complete and valid value, but instead the possibly partial and wrong-case value just as typed by the user. I.e., the the change event's submission of the value precedes the autocomplete's substitution.
The answer that #VincentDeelen gave is the best alternative that I can see, although it doesn't quite give that "instantantenous synchronicity" feel. You could maybe use the "Key Down" event, but be careful with that. You could get a really excessive amount of web and db traffic as each and every keystroke (including corrections) results in another firing of the dynamic action.
Testing environment: ApEx 4.2.3 with Chrome 33 as well as IE 9.
p.s. This might be worth a mention to the ApEx development team as well.
It's not really ideal, but you could use onfocus(). I'm looking for the same thing you are, I think, a custom event that fires when the selection of a suggested value happens. I haven't found it yet though and that is my work-around for now. It will run whatever function you've created for this initially with no value, but once the selection is made it will return focus and run the function again with the right value. Like I said, not ideal but it works.
Jeffrey Kemp is right. You can set it up through a dynamic action using the custom event, result. You can also register it on page load using document.getElementById("{id}").addEventListener("result", {function}); or $("#{id}").result( function( event, data, formatted ) { //something here });.
Oracle apex 19 now added a "component event" when you create a dynamic action called "Update [Text Field with autocomplete]" - this action is fired when you select a value from the list, but not when you leave the field (similar to adding the custom event "ojupdate").

Resources