I am using MS CRM and USD where I am suppose to create a toggle button using WPF hosted control. I followed the tutorial over here.However I want to change the text of button after it is clicked.
To do literally what you describe may require more effort and complexity than a resonable alternative, so I want to explore both of those possiblities here.
The Desired Answer: Replicating Toggle Button Behavior on Non-Toggle USD Buttons
Set the Button's label to a $Context parameter, like [[$Context.ToggleButtonText]]. Be sure to push this value at DesktopReady using your Global Manager's CopyToContext action. We'll use this label to define the state of the button, so let's say that we'll only push values "On" and "Off" to this parameter.
Similarly, set a $Context parameter to indicate whether the button is changing, like [[$Context.ToggleButtonIsChanging]]. Upon DesktopReady, set this to false. The same Action Call can push both ToggleButtonText and ToggleButtonIsChanging to $Context simultaneously.
Define three Action Calls for the button click.
3a. The first Action Call will set ToggleButtonIsChanging to true.
3b. The next two Action Calls should be given names like "Toggle Button to Off" and "Toggle Button to On". Both Action Calls should do nothing but perform a condition check, thereby authorizing or preventing their Sub-Actions from firing. (More on defining these Sub-Actions to come.) I recommend using the Global Manager's Pause action to perform a 1ms Pause when the condition is true.
3c. For Toggle Button to Off, the Condition should be "[[$Context.ToggleButtonText]]"=="On"&&[[$Context.ToggleButtonIsChanging]]. For Toggle Button to On, the Condition should be "[[$Context.ToggleButtonText]]"=="Off"&&[[$Context.ToggleButtonIsChanging]].
Define Sub-Actions for "Toggle Button to Off" and "Toggle Button to On."
4a. The first Action Call (and if necessary, any of its Sub-Actions) should perform the desired automation(s) that would correspond to the Button's state change. In other words, what the button actually does goes here.
4b. The second Action Call should finalize the button's state change by pushing new $Context parameters. Under "Toggle Button to Off," you want this action to set ToggleButtonText to Off and ToggleButtonIsChanging to false. Under "Toggle Button to On," you want this action to set ToggleButtonText to On and ToggleButtonIsChanging to false.
A Simpler Suggestion: Separate Buttons with Visibility Conditions
Define two buttons, "On" and "Off."
Upon DesktopReady, push a value "On" or "Off" to [[$Context.ButtonState]].
Define Visibility Conditions for both buttons. For example, the On button should only be visible if "[[$Context.ButtonState]]"=="On"
Define Automations for both buttons. You'll need at least two Action Calls.
4a. For each button, your first Action Call(s) should define the desired automation(s).
4b. The very last Action Call under each button should push the converse value to $Context. For example, the On button's final action should CopyToContext ButtonState=Off.
Related
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.
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").
I need help in figuring out the event that is fired when I select a dropdown value from dijit.form.Select. I already know of the onChange event and would like to know an event which fired even when the value is not changed.
Use Case
I am using dijit.form.Select in my project. I have some values like {Multiple,a,b,c,d} in this select drop down. When I select Multiple then it launches the pop up dialog. When I select other values a,b,c or d then that value gets set in that drop down.
Currently I catch onChange event to check if user has selected "Multiple" value so that I can launch the pop up dialog.
Now here is one issue. 1. Lets assume that by default selected value is a. 2. Now I select Multiple, onChange gets fired and pop up dialog gets launched. 3. Now again if I select Multiple then onChange event won't be fired and thus code would not launch pop up dialog.
I want to launch this dialog every time user selects "Multiple" value in the dropdown. Any suggestions to do this? I have tried useing onClick, onBlur and onFocus events but they are not of much use to me.
Please help.
You can Capture the 'onExecute' event of the dropDown of the dijit.form.Select widget for this behaviour. However, keep in mind that you wont get the newVal as an argument to the function for this event. to get the new value, use the following line as the first line of your function:
var newVal = this.focusedChild.option.value;
This will work for sure :)
I am using TaskDialog API in a win32 app. I created a Task Dialog with YES/NO buttons but I can't find any option to set the No button as default. YES button is always the default. Please let me know if there is a way to set the NO button as default. I know TaskDialogIndirect supports a default button option but its an overkill for what i am trying to do. I just want a simple YES/NO Dialog with NO button as default. I did not want to use the MessageBox API because i don't want a close button in the titlebar.
Thanks,
Abhinay
Given:
TASKDIALOGCONFIG tc;
Set the default button by setting the nDefaultButton member, e.g.:
tc.nDefaultButton = ...;
"This may be any of the values specified in nButtonID members of one of the TASKDIALOG_BUTTON structures in the pButtons array, or one of the IDs corresponding to the buttons specified in the dwCommonButtons member:
IDCANCEL Make the Cancel button the default.
IDNO Make the No button the default.
IDOK Make the OK button the default.
IDRETRY Make the Retry button the default.
IDYES Make the Yes button the default.
IDCLOSE Make the Close button the default."
The above bit shamelessly quoted from MSDN.
So basically, if you're using the standard predefined buttons, set the field to one of the above constants; if you're using a custom button, set it to the ID you use when specifying the button.
In addition to answer given by David, I would add my two cents - If you are using MFC, you may use CTaskDialog class.
I have called a leave event for a a text box and in it called another buttons event named Retrieve button. so now I just want to check in this retrieve button event weather the text box's leave event is called or not?
When you call the retrieve button event from the text box leave (blur) event you could simply add a flag into the eventArgs that you can check in the retrieve button. This flag would only be set when you implicitly call the retrieve button even from the text box leave event.
This would mean that if the retrieve event is called from other places the flag would not be set so you could tell that the call definitely came from the button leave event.