A Name Text Box is bounded to a Names field in the related Notes form.
How to make the values in the textbox into be converted automatically to CANONICALIZE when XPage is saved?
I have tried the following but they all failed.
A) Saving the form using currentDocument.save()
B) Use simple action "Save Document"
C) add #Name([CANONICALIZE], #ThisValue) in the associated Notes form field under input validation, input translation and even as computed field.
The OpenNTF Domino API has an openntfNABNamePicker dataProvider that you can use on a Name Picker control which provides this functionality. It has a returnNameFormat property to allow you to define whether the name should be stored in Abbreviated, Common or Canonical.
It may be possible to use a Converter as well, so that the name is converted to and from canonical format between browser and server.
Try
document1.replaceItemValue("yourField", #Name("[CANONICALIZE]",document1.yourField));
in the querySaveDocument event of your xpage,
where document1:
<xp:this.data>
<xp:dominoDocument var="document1" ... />
</xp:this.data>
You can also use the following code in your save-script:
var name:NotesName = session.createName(getComponent("inputText1").value)
document1.replaceItemValue("NameNA", name.getCanonical())
document1.save()
NameNA is your notes field of type "names" and "document1" is your datasource.
The canonicalize needs something to work with. "John Doe" doesn't turn magically into "CN=John Doe/OU=ThePitt/O=GI"
Without a directory to find the name only something like "John Doe/ThePitt/GI" would canonicalize properly.
You could use #NameInfo to check if you can get the fullname back from a directory.
The conversion is easy and no coding is involved using the OpenNTF Domino API.
I found myself looking for ways to resolve the issue above myself in my project, while Paul provided the answer, it took me a while to really understand how to go about it.
I'm adding an image below just to help anyone that may find themselves in a similar situation. It shows where to go to change the valueNameFormat property
Related
I have created a multivalue field in a dialog and it looks like this when I initially open the dialog:
Is there any way to have it display the field(s) necessary to create the first option when the dialog first opens? This is how we want it to look:
I have looked through the documentation and I could not find a way to accomplish this, but I thought I would ask before telling the designers 'no.'
Thanks for your help!
You need to customize multivalue field to achieve it.
Create your own field factory by extending info.magnolia.ui.form.field.factory.MultiValueFieldFactory<D> in extended factory override createFieldComponent() and once field is initialized (e.g. by calling super.createFieldComponent()) you can add the first option you wanted programatically.
You might have to also tweak transformer or saving of the field to not save empty option if it doesn't do that already ootb.
How to get visible attributes from entity form using c# in custom workflow?
Any idea please share!
It's a PITA but it's doable.
retrieve the form you want to process from the systemform entity (you want the formxml attribute)
the formxml attribute contains the form definition, it's encoded (< is written as < and so on) xml format.
Inside the formxml contents, a field looks like this:
<cell id="(guid)" labelid="(guid)" showlabel="true" locklevel="0" visible="false">
<labels>
<label description="(field label)" languagecode="1033" />
</labels>
<control id="(field name)" classid="(guid)" datafieldname="(field name)" disabled="false">
parse the xml, looking for cell elements which do not have visible attribute (it's only there if the field is hidden)
you might have to narrow the list down through further searches in xml (not 100% positive about what i.e. a subgrid would look like) but I have no direct experience with this kind of logic so I can't pinpoint each and every corner case
Pain point: You won't be able to tell if a field visibility has been toggled through javascript
What do you mean visible attributes? You mean attributes with a value or attributes showed in the form? If it's the second the only way that you have to keep track of that is use a text field and use some code to identify what is active.
ex. create a text field
and write in it all the fields that are visible ex name and surname:
"name","surname"
You can manipulate this with javascript and business rules to keep the list of fields updated at every time for each record. In the code behind you just need to read for the text field and manipulate the magic string.
It's not a really nice operation, but is the only way i can see to keep track of what fields are shown on the form.
This seems like it should be easy to do but I cannot get it done.
I have an Xpage called Location. There are two general types, A and B. I have a series of views for A and B. They are the same except for the value of that one field.
In the views I want my "New Location" button to automatically populate the type to A or B, depending on whether the user is in one of the A views or B views.
Seems like I would set a scoped variable and then check for that on document creation, but it doesn't seem to work. What is the best practice to do this?
Jesse Gallagher's frostillicus framework on OpenNTF (XPages Scaffolding - http://openntf.org/main.nsf/project.xsp?r=project/XPages%20Scaffolding&SessionID=DN6QBBFGEB) includes flashScopes, which give the facility to pass information from one page to another and get cleared when the page is loaded.
You can use sessionScope variable to transfer data from one XPage to another.
A better approach might be to use URL parameter for your case.
Add for example &type=A to your URL like
http://server/database.nsf/Location.xsp?action=newDocument&type=A
Then you can read this parameter in your destination XPage with param.type like
var type = param.type;
The disadvantage of sessionScope is that it's the same for all browser tabs. So, you need to delete it right after usage in this case. Using an URL parameter instead you don't have to think about that.
I am using a "document library" (template: StdXLWebXDocLib).
I can record more than 30 files(attachment) in the same document, but I can only see 30.
Even if I change the Row value.
Is this a XPAGES bug ?
Anyone know the solution?
(with the Notes client, I see them all)
Thank you for your help.
Search in database for string "xp:fileDownload" in Designer. It will show you as result:
Replace in all three design elements rows="30" with rows="0". Then it will show always all attachments.
Afaik the default entries per page of the xpages repeat element (which might be used in this case) is 30. They might just not have added a pager to it.
I don't know that template but if you mean the File Download control you can set the value of the lines to display to 0 to not restrict them so that you can see all attachments available.
You can find that property in "All properties, data, rows".
There is a lot of questions about binding data to forms. This is very simple. I have a form that uses several computed fields that pull data using an #DbLookup to populate the fields based on a pulldown menu the user selects. The problem is; none of the computed fields save any of the values into the form that it is bound to. The only data that saves on the form is the data that is manually selected (in the case of the pulldown menu) or manually entered. When I use an edit box and don't make it "Read Only" the data saves fine. Why is this so difficult?
Mark -
Couple approaches here I think... but let's walk though something.
Read Only on the edit box is preventing the save. It makes sense. XPages should not try to save something marked "read only".
As Steve says, you're better off here with a computed field. Set the values however and if their bound to the document then I think they will save fine.
Another approach is is to work with scoped variables. When you get your data points... you can put that into scoped variables like:
viewScope.put("myField", myValue)
then you're computed field could be bound to the viewScope variable "myValue".
however this will of course not save back to the document as it's not bound to the document. So what you do if you want that approach is in the document save event... you then use SSJS to assign the values to the doc then. something like:
document1.replaceItemValue("myfield", viewScope.get("myField");
Since xpages basically has the same document events as notes client. This may seem familiar to you.
Hope this helps.
Dave -
NotesIn9.com
Disclamer: I'm answering this from a plane after a trip to Las Vegas. So please factor that into the quality of my answer. :)
You will want to put the data you receive from the #DbLookup in an edit box field(s). A computed field is like a "Computed for display" field in traditional Notes development. You can choose whether to allow the user to change the values or not by the read-only property.
Also see this question if you want the values read-only which it sounds like you do: ReadOnly field in Xpage not submitted
As usual, Dave steered me to something that worked. Being in the larval stages of JavaScript experience, I'm sure there is a better way to do this. I'm just happy it works. Her is the code I put into the QuerySave event of my Xpage.
var cost1 = getComponent('ItemCost1').getValue();
var uom1 = getComponent('UOM1').getValue();
var Num1 = getComponent('ItemNum1').getValue();
var tot1 = getComponent('Total1').getValue();
docuent1.replaceItemValue("ItemCost_1", cost1),
document1.replaceItemValue("ItemUOM_1", uom1),
document1.replaceItemValue("ItemNum_1", Num1),
document1.replaceItemValue("CostTotal_1", tot1)
I have 30 iterations of this so it probably works kind of clunky but the operative word is WORKS. If anyone has a better way to get the same results, please post it so I can learn something. Thanks for everyone's help.