I am trying to understand what exactly is stored in an event using the SAPUI5 documentation here. Where can I find a list of parameters that come with an Event? For example, I just found out that DatePicker has a parameter called "valid", but how would I know that? Surely I wouldn't have to use getParameters() for every entity right? Also when you define a function to be called in XML, do they all send the same Event type?
In general the parameters depend on the intention of the event, e.g. a change event which indicates that the source object has changed its value contains other parameters than an event which informs you that a file upload has failed.
You'll find the available event parameters in API documentation. To stick with your example: Check the API documentation of the DatePicker control, select the change event from the available events and check the available parameter. You will find the parameter valid with a description. To see the difference between the events you may also check the ListBase implementation, which defines a bunch of events.
It is good style to use getParameter in your event handler to access the parameters values.
onDatePickerChanged : function(event) {
let validDate = event.getParameter("valid");
}
Related
In case, I use the Event Information Update (PATCH /users/{id | userPrincipalName}/events/{id}) API, how is the content change (body.content) judgment made?
Thank you for reaching out. Per the update event documentation values that should be updated should be supplied in the event body. Existing properties that are not included in the request body will maintain their previous values or be recalculated based on changes to other property values. In this case, the body should change only if supplied in the request.
Let me know whether this helps and if you have further questions.
I want to trigger event on user registration like this
FB.AppEvents.logEvent("Registration");
but how can I pass both the valueToSum and parameters arguments to this custom Event?
and likewise How can I pass custom parameters to my predefined Events like FB.AppEvents.EventNames.ADDED_TO_CART?
Like this:
FB.AppEvents.logEvent(
FB.AppEvents.EventNames.COMPLETED_REGISTRATION,
valueToSum /* number */,
customParams /* Object */
);
I'd recommend using FB.AppEvents.EventNames.COMPLETED_REGISTRATION instead of "Registration" since it's one of the predefined events.
The above example also shows how to pass custom parameters to predefined events.
You can find more information here: https://developers.facebook.com/docs/app-events/web
Out of curiosity, what do you need valueToSum for on a registration event? Registration typically isn't something that needs an aggregate value.
I'm trying to understand the plug-in sample from here.
There's this condition:
// The InputParameters collection contains all the data passed in the message request.
if (context.InputParameters.Contains("Target") &&
context.InputParameters["Target"] is Entity)
Speaking generally, not just with regard to this sample, on what prior knowledge should I base my decision to access a specific property? How could I have known to test whether the InputParameters contains a "Target" key (I assume I'm not supposed to guess it)?
And on what basis could I have known to ask whether the "Target" mapped value is of Entity type, and not some other type?
I found this post from 2 years ago, and I've found this webpage, saying (emphasis is mine):
Within a plugin, the values in context.InputParameters and
context.OutputParameters depend on the message and the stage that you
register the plugin on. For example, "Target" is present in
InputParameters for the Create and Update messages, but not the
SetState message. Also, OutputParameters only exist in a Post stage,
and not in a Pre stage. There is no single source of documentation
that provides the complete set of InputParameters and OutputParameters
by message and stage.
From my searchings, a single source still doesn't exist, but maybe the possible values can be found using the Dynamics Online platform, somewhere deep down the Settings menu, maybe? Any source would be great.
I know this is an "old" question that already has been answered, but I think this can be helpful. I've built a small web page that contains all the messages with all the Input/Output parameters. You can access it from here:
The best practice for doing this is to use a strongly typed approach. If, for example, you want to know which propertes are available on a CreateRequest, you would do:
var createReq = new CreateRequest() { Parameters = context.InputParameters };
createReq.Target; // Has type Entity
Take a look at the full blog post explaining this approach: Tip: Proper handling of Plugin InputParameters
Original answer:
It depends on which request we are talking about. See Understand the data context passed to a plug-in on MSDN.
As an example, take a look at CreateRequest. One property of
CreateRequest is named Target, which is of type Entity. This is the
entity currently being operated upon by the platform. To access the
data of the entity you would use the name “Target” as the key in the
input parameter collection. You also need to cast the returned
instance.
Note that not all requests contain a Target property that is of type
Entity, so you have to look at each request or response. For example,
DeleteRequest has a Target property, but its type is EntityReference.
In summary: Look at the actual request, e.g the CreateRequest.
In 2011 someone actually generated typed properties based on the message type. Kind of neat: https://xrmpalmer.wordpress.com/2013/05/27/crm2011-plugin-inputparameter-and-outputparameter-helper/
It would show you want parameters are possible per message.
I'm looking at the
documentation
for triggering events in OpenLayers. It lists triggerEvent as taking in a type:String argument and a evt:Event argument. I understand what the type parameter is, but what object is the Event object? I can't find a clear example.
If it is relevant, I am working on an interface between Google Maps v3 and OpenLayers, and I'm trying to come up with a way so that I can have a the same API interface to calls to:
google.maps.event.trigger(instance:Object, eventName:String, var_args:*)
openLayersObj.events.triggerEvent(type:String, evt:Event)
Doc is wrong. It should be Event || object. Object that will be args passed to the listeners callback.
Look at the source: https://github.com/openlayers/openlayers/blob/master/lib/OpenLayers/Events.js#L820
Example of use: https://github.com/openlayers/openlayers/blob/master/lib/OpenLayers/Map.js#L1042
How can I put a new event at the top of all attached events linked to an object just after the page load?
Pratically I have an accordion using some YUI funcs to activate its behavior, now without modifying the YUI main function I need some new functions used to call AJAX routines.
Currently I am trying with Event.getListeners, but I don't know how to treat the returned objects.
Regards
The responses you get from Event.getListeners is all the arguments passed into the Event.addListener. According to the docs for Event.getListeners it returns
the listener. Contains the following fields:
type: (string) the type of event
fn: (function) the callback supplied to addListener
obj: (object) the custom object supplied to addListener
adjust: (boolean|object) whether or not to adjust the default context
scope: (boolean) the derived context based on the adjust parameter
index: (int) its position in the Event util listener cache
So using that object you can probably just remove the Listeners using Event.removeListener & then re-add them all in the order you want using Event.addListener. The object's properties map 1:1 with the args for Event.addListener so nothing will be lost.