Retrieve explicit values from document library - sharepoint-clientobject

I'm trying to pull some fields from my Document Library. Right now, I can retrieve these 2 fields to return the correct values, in my success function.
while (listItemEnumerator.moveNext()) {
var oListItem = listItemEnumerator.get_current();
alert(oListItem.get_item('Title'));
alert(oListItem.get_item('UserField1'));
}
But when I try to call a computed field, such as 'NameOrTitle' oListItem.get_item('NameOrTitle')); I get IE telling me the property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.
This value has content inside it right now. And I need it, as it's displaying the file name. How can I get this field? I have looked elsewhere and I have read stuff about doing:
context.load(allItems, 'Include(NameOrTitle)');
Then in my succeess function, I do oListItem.get_nameOrTitle(). Is this correct?
Well I do that and now I'm getting
Object doesn't support property or method 'get_nameOrTitle'
Please help. Thanks.

oListItem.get_item('FileRef');
Will get me the url

Related

How to update mark a form dirty after a server side modification

I don't understand how to make the Client ui aware of a server side change in a document.
My use case is the following : I'm adding a button to my form, that calls a custom document method :
In MyDocType.py, I have :
class MyDocType(Document):
#frappe.whitelist()
def change_some_value_in_doc(self):
self.the_field_i_want_to_change = 50
It work in the sense that the_field_i_want_to_change is immediately updated to the new value.
However, If I hit Save, I get the message "No changes in document". I managed to determine that this is because on the JS side, the form is not marked as "dirty", but despite reading the documentation over and over, I cannot find the right way.
I tried with self.notify_update() which seems to have no effect.
Is it a bug ? Or am I misunderstanding how this is supposed to work ?
I'm using frappe v 14.0.0-beta.3
[EDIT]
Actually, I realized that doing
class MyDocType(Document):
#frappe.whitelist()
def change_some_value_in_doc(self):
self.the_field_i_want_to_change = 50
self.save()
Does work in the sense that it save the new value, but it's not exactly what I'm looking for, because my purpose is actually to pre-fill some data with the custom method and leave to the user to complete before saving...
Any help to get me in the right direction would be very appreciated.
To pre-fill data in your form - that you want the user to confirm before saving to the database, you should use client-side scripting (in JS). Changing the value on the server is not going to help you since you want the user to get pre-filled values before inserting a record in the database.

Uncaught (in promise) FirebaseError: Invalid document reference. Document references must have an even number of segments

Well, My issue is different.. I created a modal form like this:
Modal Form
There is no issue at all and my data can be edited easily:
Updates with no errors
Now, I started to replace the text area with Vue2-editor plugin and the resulting design is like the following:
Vue-text-editor
I tried to modify the texts and save:
Error
Here is my updating mechanism:
updateProduct() {
// Update function has issues so I have to apply this work-around
this.$firestore.products.doc(this.product['.key']).set(this.product).then(() => {
this.$firestore.products.doc(this.activeItem).delete()}).then(()=>{
this.$refs.edit.hide()
toast.fire({
type: 'success',
title: 'Updated successfully'
});
});
},
Well, the firebase update function does not work at all. I have researched this, but in vain - this is the only working workaround for it.
Now I need to figure out what's wrong with that text editor.
Your problem is here:
this.$firestore.products.doc(this.product['.key'])
I don't know what the contents of this.product['.key'] is, but it's almost certainly not going to give you the name of a collection and the name of a document together. The only way you can reference a document is through a collection. Documents don't exist outside of collection. That's why the number of path segments in the string you pass to doc() must be even. It should be of the form "collection/document".
You will have to identify the collection you're writing to, and reference the path of the document using it.

How to filter options in app maker's SuggestBox

I need to implement filtering for options in SuggestBox.
I've tried to do it differently, but none of my attempts worked out:
Using Model instead of Options/Value; Create calculated SQL model and pass the parameter for filtration:
Didn't work: suggestBox doesn't have event or anything to call before it loads data, so if you pass param for query before typing anything in -- it is not seen an you get an error:
Please provide value for the parameter ":Param" used in the query Error: Please provide value for the parameter ":Param" used in the query
Query for record suggest oracle: (Error) : Please provide value for the parameter ":Param" used in the query
Query for record suggest oracle failed.
Using Options/Value
It seems that it is impossible to have different properties of an object when passing it to Suggest Box. For example, I want user to see an user-friendly field Name and work with a record or at least record's Id, but if you specify Name as an option and Id as a value, Name is being written to a SuggestBox and now we get a validation error because Name is a string and Id is a Number.
Please help me realize where I'm wrong or show me a workaround for this.
Thanks!
I had the same issue as well. I gave up on the suggest box and created a pop up form. With a query builder model for the data source. The only thing i don't like is that it seems to be case sensitive.
something like:
YourFilterColumn startsWith? :Param
Add a table view and then you can add a text box and set the oninputchange event to:
widget.datasource.query.parameters.Param = widget.value;
widget.datasource.load();
Then you can start typing select the record you want and pass it back to your form with a button.
like this if it is a relational field:
app.pages.YourPage.children.YourForm.datasource.item.YourItem =
widget.datasource.item;
or something like this if you just need a value (haven't tested this):
app.pages.YourPage.children.YourForm.datasource.item.YourItem =
widget.datasource.item.YourValue;
Probably add a couple lines to clear the form out:
widget.root.descendants.TextBox1.value = "";
widget.datasource.query.parameters.Param = "";
widget.datasource.load();

Trying to figure out what this line of code means

This code is from a program I use to enter and track information. Numbers are entered as work orders (WO) to track clients. But one of the tables is duplicating the WO information. So I was trying to figure out a general outline of what this code is saying so that the problem can be fixed.
Here is the original line:
wc.dll?x3~emproc~datarecord~&ACTION=DISPLAY&TABLE+WORK&KEYVALUE=<%work.wo%&KEYFIELD=WO
What I think I understand of it so far, and I could be very wrong, is:
wc.dll?x3~emproc~datarecord~&ACTION
//No clue because don't know ~ means or using & (connects?Action)
=DISPLAY&TABLE+WORK&KEYVALUE
//Display of contents(what makes it pretty) and the value inside the table at that slot
=<work.wo%&KEYFIELD
//Calling the work from the WO object
=WO
//is Assigning whatever was placed into the WO field into the left side of the statement
I'll do my best to interpret the statement, with the limited information you've provided:
wc.dll is an instruction to invoke a DLL
? is introducing a list of parameters (like a query string in HTTP)
x3~emproc~datarecord~ seems like a reference to a function in the dll
& parameter separator
ACTION=DISPLAY set the ACTION parameter to the value DISPLAY
TABLE+WORK perhaps sets a couple of flags
KEYVALUE=<%work.wo% set the KEYVALUE parameter to the value of <%work.wo%
KEYFIELD=WO set the KEYFIELD parameter to the value WO
Hope that helps.

How to read the filter variable in a php code block in views 2?

I'm trying to create an img link manually with php in the header field of a view, in drupal 6. I need to read the value of one of the filters, but can't find the right variable to read. I thought I could print_r($view->filters) but it didn't give me anything, and I eventually found out that isset($view) is false.
Am I looking the wrong way?
The context I'm writing in is the header field of the view, with php code as input format. Do I have to "enable" the $view variable for reading in this context somehow?
OK I found it, it was really easy:
$pa_view = views_get_current_view();
$pa_nr = $pa_view->display['default']->display_options['filters']['field_nummer_value']['value']['value'];

Resources