I'm working with calendar information in the XML response from the MS server. I successfully extract fields from CalendarItem, but I also need some of the fields from CalendarItem's ancestor, Item. The response from the server contains that information in xml, so I believe I can use "from_xml" to get, for example, the "item:TextBody".
If "from_xml" is the right approach, how should I use it? If I'm on the wrong path, how should I proceed?
What exactly are you attempting to do? exchangelib makes all values in the XML available as attributes on the returned items. There are lots of examples in the documentation.
CalendarItem is a subclass of Item so the fields on the superclass are also available to the subclass. You can see all available fields by renting CalendarItem.FIELDS.
Related
Invoice Parser documentation lists the fields that this processor attempts to find in a document.
https://cloud.google.com/document-ai/docs/processors-list?hl=en_US#processor_invoice-processor
I am only interested in some of the fields in the Invoice processor, is there a way to get the list of fields and request the processor to find the data points for a selected set of fields?
E.g. I am only interested in invoice_date and invoice_id. So, the processor only finds these two fields for me and does not waste its time finding others.
I found an endpoint that retrieves the processor's details but it does not get the field list.
https://cloud.google.com/document-ai/docs/reference/rest/v1beta3/projects.locations.processors/get
This process endpoint does not have anything to specify the fields that I am interested in.
https://cloud.google.com/document-ai/docs/reference/rest/v1beta3/projects.locations.processors/process
My research indicates that this feature does not exist, hoping someone tells me that I am wrong.
Currently, it's not possible to limit the specific entities that are extracted by a specialized processor. The processor will always processes the entire document and extract everything it can find.
However, a new parameter has recently been added to the process method in the REST API that lets you provide a fieldMask to limit the fields that will be returned in the Document object. This has also been added to the How-to Guide for making a processing request. Currently, this only works for the REST API (not client libraries) and online processing.
This isn't exactly what you're looking for, but it can significantly limit the size of the Document response if you don't need fields like content
I will need to save a serialized data in a field. Can anybody please help me figure out how can i do it in sitecore.
In a sql server I can define xml field-type which is sufficient for this. But similarly I can't find anything in sitecore. Though there are two types called html & memo which are deprecated. Also want to know can I use any of these.
We are using sitecore 7.2 BTW.
You can simply store it in a multi-line text field. If you wanted to get real fancy then you could create a custom field type. I've previously even used an IFrame field type for this kind of data, since the text is blanked out to the end user (but still viewable using Raw Values) and since the underlying data is just text it worked fine.
In any case, if your field is populated automatically from an external source then you probably don't want that data editable from the content editor. Lock the field down using the security editor and using correct roles & permissions so that normal editors do not have Field Write permissions (set on the template itself, not the created items)
In Sitecore, all fields are internally kept as strings by design (except media blobs). I think the best field type to store serialized XML would be multi-line text.
Of course, you should care about all serialization and deserialization the data into that field
Summary
I have a bit of a problem using Ember-Model, trying to establish a unique relationship between two models.
Based on current responses that I have received here on S.O., Ember Forums, and #emberjs. I am beginning to believe that there is no built-in solution for this problem, and I am reformatting my question to specify what is needed.
Details
I am populating a template currently with a full set of debtor information. All the information comes from multiple calls to the server.
The first bit is the basic Debtor info. This part is easy because I can use the model hook and a dynamic segment to retrieve it.
My server returns a JSON for a Debtor... Here's the short version:
{
"debtor" = {
"debtor_id": 1003,
"debtor_name": Steve,
//... more JSON
"debtor_contact_id": 1345
}
}
The dynamic segment for Debtor is filled with the value of the debtor_id, but also notice this debtor has a debtor_contact_id. Every Debtor record retrieved from the server has a unique debtor_contact_id. On the database, this value is a "foreign key" that will tell which contact table belongs to which debtor table.
There is no way to predict which contact info relates to which debtor without this key/value pair.
I currently have "Contacts" belongsTo "Debtor", but that is not enough to do the job.
When it is time to fill the "Contacts" model. Ember-Model needs to know to build the value from debtor_contact_id into the ajax URL as a query parameter in order to GET the correct API.
I am still learning all of this stuff and so far I have not been able to fully follow any tutorials because my use case has an extra step needed somewhere.
This is the expected behavior I am hoping to see:
Model hook will work as expected to pull the specific debtor and put it into a "debtor" model (this part is currently working just fine)
Somehow "debtor_contact_id" is read from the payload
that value is added as part of a server query to find a separate API
the resulting contact info will be pulled into a "contact" model
hopefully a hasMany/belongsTo relationship can be established after both corresponding models are returned.
all this needs to be done in one promise before entering my template
You will also find the question at: discuss.emberjs.com if that is more appropriate place to discuss.
I can elaborate more if this does not make sense... thanks!
Assuming you are using ember-data, alongside the attributes of your model you need to add:
debtor_contact: DS.belongsTo('name_of_the_other_model')
This then provides you a promise which will resolve to the other model on demand. It won't resolve straight away, but bound variables in templates will update as it is resolved. The other API call will be made for you if things are set up properly.
http://emberjs.com/api/data/classes/DS.html#method_belongsTo
The answer I gave here might also be helpful if you need to force resolving the relationship for some reason: Ember Unbound & Belongsto
I'm starting to use the Graph API to get my notifications, and in the REST interface, they had the object_id field. I used this to get the notification objects' id to then query the Graph for more information.
The Graph API object does not include this information.
Example of what I want to do:
Get user's notifications JSON object.
Grab single item
Identify if this item supports commenting/liking
Display comments and number of likes for that item
if user can comment or like item, display buttons for this
my process:
call me/notifications/?include_read=1
is pretty easy to do.
I can identify if the object refers to a group, event, random application, post, or photo using the URL. I know that posts, likes, photos and others support commenting/likes so I have a way of doing this, though it involves parsing the link attribute of the item
this is what I need help with. I can get the id of the object by parsing the link, but I don't get the full object some times using this. For example, to post on a comment, you need to have USERID_COMMENTID and the link only has the COMMENTID in this form http://www.facebook.com/USERNICKNAME/posts/COMMENTID
I also need help with this. I guess some fb objects can't been liked via the graph?
any help would be great!
The notification FQL table, which also replaced the REST notifications.get API, still has an object_id column. That's the closest thing that exists to what you're asking for. It doesn't look like the Graph API call is documented to have the object_id field unfortunately.
I am listing products as table rows, each row contains input fields for specifying the quantity of products.
I made a Fiddle for it here, http://jsfiddle.net/kroofy/4jTa8/19/
As you can see, after the input in the Qty field have been made, the whole row render again. And because of that the focus of the input field will be lost, which is not good if you want to input more than just one digit, or tab between input fields.
What would be the most elegant way to solve this?
I would handle this by setting model.set({qty: _qty}, {silent: true}) and then updating the non-input fields with this.$.
As an alternative to the silent treatment: rather than listening for change events, listen for change:qty and change:sellPrice and have a method that updates just the HTML that needs updating within this.$, rather than re-rendering the DOM object and breaking your focus.
Either way, your comment about "selective updating" on the fiddle is certainly the right way to go.
(this.$ is a backbone hack to jQuery that restricts all selectors to search only within the DOM of the View's element. The element doesn't even need an ID or class; it just needs to exist and the View maintains a handle to it. It's incredibly useful.)
i built a plugin for backbone called Backbone.ModelBinding that may be able to help in this situation. my plugin allows you to update portions of a view with data from a model, when the model changes.
i've forked / updated your fiddle to show it in action: http://jsfiddle.net/derickbailey/FEcyF/6/
i removed the binding to the model change. i've also added id attributes to the inputs of the form to facilitate the plugin (the attribute that the plugin uses is configurable, though). and lastly, i've added a data-bind attribute to the sell price total td.
you can get the plugin here: http://github.com/derickbailey/backbone.modelbinding/
hope that helps
FWIW: my plugin is an automated version of what Elf is suggesting. I've written code exactly like he is describing, numerous times, which is where the plugin came from. I just got tired of writing that code by hand :)