ODK Dynamic select from database, how to handle empty list - select

I have an ODK form that is configured to get a list of data from the database and use that list of data for the select.
Problem is that I am not able to display an error for when the query from the database returns an empty string, instead, ODK form crashes while loading. I have tried this,
<instance id="books">
<list>
<g:if test="${Book.list()}">
<g:each in="${Book.list()}" var="book">
<book>
<id>${book.id}</id>
<name>${book.name?.encodeAsHTML()}</name>
</book>
</g:each>
</g:if>
<g:else>
<book>
<id></id>
<name></name>
</book>
</g:else>
</list>
</instance>
which creates an xml with an empty id and empty name. This makes sure that the ODK doesn't crash when it loads.
But since I don't want the user the select an empty book option, I added a constraint in the bind nodeset section,
<bind nodeset="/form/book" type="string" required="true()" constraint=". != ''" jr:constraintMsg="Book must be not be empty"/>
So now when the user tries to get past the book selection section the ODK form doesn't allow it, but instead of throwing the constraint message that I supplied it throws this error
don't know xml value! perhaps selection was stored as index only and has not yet been linked up to a formdef?

Related

Disable form fields in Sulu's admin frontend after the entity has been persisted

I'd like to connect the key of a category in the Sulu CMS with specific business logic. But therefore the key must not be changeable in the admin area. Is there a way to disable a form field once the entity is persisted?
It's possible to override any form configuration by creating a file with the same name and the same <key> in the config/forms/ directory of your project. In case of the category details form, create a config/forms/category_details.xml file with <key>category_details</key> containing only the properties you want to override, in your case the <property name="key">. You can omit the other properties, because all the form configurations with the same key will be merged together. Then you can use a disabledCondition to configure when this property should be disabled and when it should be possible to edit, in your case something like disaledCondition="!!id", because then the property is only editable, as long as it doesn't have an id, which is only the case when you create a new category. You probably also want to add the mandatory="true" attribute, if your application depends on the key of a category. So the whole file should look like this:
<?xml version="1.0" ?>
<form xmlns="http://schemas.sulu.io/template/template"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://schemas.sulu.io/template/template http://schemas.sulu.io/template/form-1.0.xsd"
>
<key>category_details</key>
<properties>
<property name="key" type="text_line" mandatory="true" disabledCondition="!!id">
<meta>
<title>sulu_admin.key</title>
</meta>
</property>
</properties>
</form>

Data binding of lightning:input and aura:attribute with type sObject(field) is not working

There is a weird scenario I'm facing while I try to bind the markup UI tags with lighting aura:attribute as type sObject (fields).
I'm trying to bind data to sobject's fields for different lightning:input tags,
For one sObject attribute the binding works perfect, but in the same way for another sObject the data is not getting bound.
For Ex:
<aura:attribute name="student" type="JN_Student__c" access="global" default="{'sobjectType' : 'JN_Student__c'}" />
<lightning:input aura:id="requiredVal" name="lastName" label="Legal Last Name"value="{!v.student.JN_Last_Name__c}" maxlength="20" required="true"/>
this works perfectly and the data persists as I show/hide this section.
WHEREAS for,
<aura:attribute name="insuranceInstance" type="JN_Insurance__c" access="global" default="{'sobjectType' : 'JN_Insurance__c'}" />
<lightning:input aura:id="requiredVal" name="lastName" label="Legal Last Name" value="{!v.insuranceInstance.Name}" maxlength="20" required="true"/>
the 'v.insuranceInstance.Name' doesn't persists its value.
Please reply if anyone knows/encounted the same.

Alfresco Custom Data List Type Text Field Help Text

I've successfully created a new Data List type in Alfresco, but was struggling to figure out what the tag is called to achieve a description under a field. I consulted the Data Dictionary, but was unable to find it.
It may not exist, but the this screenshot makes me hopeful. As you can see, the Modified Date field has the DD/MM/YYYY help text under it. This is exactly what I want to put under the Program Name field, but with my own string.
<property name="orpdl:programName">
<title>Program Name</title>
<type>d:text</type>
<helptext>What's this tag called?</helptext>
<mandatory>true</mandatory>
</property>
Eeuh that's just a div in the control field for all the date fields.
Take a look at alfresco/site-webscripts/org/alfresco/components/form/controls/date.ftl
The message you see is in this div:
<div class="format-info">
<span class="date-format">${msg("form.control.date-picker.display.date.format")}</span>
<#if showTime><span class="time-format<#if disabled>-disabled</#if>">${msg("form.control.date-picker.display.time.format")}</span></#if>
</div>
So you want a string, just create your own custom controller based on textfield.ftl and put whatever string you like. Probably best to do that by passing it through the control-params.

cannot insert NULL into ("ESB"."ADDRESS_API"."LABEL_NAME_MAP")

Attempting to hit the Customers end point and the API keeps rejecting my request with this extremely nondescript error:
<ErrorCode>-3002</ErrorCode>
<ErrorDesc>cannot insert NULL into ("ESB"."ADDRESS_API"."LABEL_NAME_MAP")</ErrorDesc>
<DBErrorCode>01400</DBErrorCode>
Here is the sample XML:
<?xml version='1.0' encoding='utf-8' ?>
<Add RequestId='47e1633341s4521a24e269ad12ab3f6' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://www.intuit.com/sb/cdm/v2'>
<ExternalRealmId>111111111</ExternalRealmId>
<Object xsi:type='Customer'>
<TypeOf>Organization</TypeOf>
<Name>SampleCustomer</Name>
<Address>
<Line1>123 E. Fake St</Line1>
<Line2>Suite 1</Line2>
<City>Somewhere</City>
<Country>USA</Country>
<CountrySubDivisionCode>FL</CountrySubDivisionCode>
<PostalCode>12345</PostalCode>
<Default>true</Default>
<Tag>Billing</Tag>
</Address>
<Phone>
<DeviceType>LandLine</DeviceType>
<FreeFormNumber>123-456-4563</FreeFormNumber>
<Default>true</Default>
<Tag>Main</Tag>
</Phone>
<DBAName>Sample Customer</DBAName>
<AcctNum>51f2ce86134c03000a000155</AcctNum>
</Object>
</Add>
Any suggestions? These exceptions are super confusion. I found the one related to "ESB"."PHONE_API"."LABEL_NAME_MAP" was related to an empty phone number field. That isn't the case with this request.
You edited your post to reflect a correct tag, so this answer may no longer be relevant
My first guess would be that, per the documentation, the Address/Tag node allowable values are defined by the PhysicalAddressLabelType enum.
Tag - String - Tag (or label) that identifies the use of the address. The
values allowed are defined in the PhysicalAddressLabelType.
If you look at the allowable values, you'll see the only allowable values are:
Billing
Shipping
But you specified:
Office
Can you try specifying a valid value?
Likewise, you're specifying an invalid Tag for the Phone node as well. The allowable values are here:
https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/v2/0500_quickbooks_windows/062_enumerations/telephonenumberlabeltype
But you've specified:
Main
Can you try specifying a valid value?

iPhone: How to handle Core Data relationships

I'm new to Core Data and databases in general. Now I need to parse a XML and store the contents in Core Data. The XML looks something like this:
<books>
<book id="123A" name="My Book">
<page id="95D" name="Introduction">
<text id="69F" type="header" value="author text"/>
<text id="67F" type="footer" value="author text"/>
</page>
<page id="76F" name="Chapter 1">
<text id="118" type="selection">
<value data="1">value1</value>
<value data="2">value2</value>
<value data="3">value3</value>
</text>
</page>
</book>
<book id="124A"...
From my understanding I would need four Entities, like "Books", "Book", "Pages" and "Text". I wonder how to set the relationships correctly and how to add for example a Page object to a Book object and how to retrieve a Text object attribute's value? The tutorials I have found mostly deal with one Entity so I didn't really get the idea.. Gtrateful for any help!
No, you'd need three entities. You can think of "Books" as the CoreData database you're using. The CoreData database then includes a number of entities called book.
I think the data model you have is a bit weird, but I guess it makes sense for your application. To map it to CoreData I would:
Add the entities Book, Page, Text
Add a bookId, pageId, textId to them, respectively.
Then add a relation from Page to Book, and from Text to Page.
By then you should be able to print out a whole book by asking for all Pages that have
Book = the book you're interested in
and then order all those Pages by their pageId
and in order, ask for all texts that have
Page = the current page
then order those Texts by their textId.
What might be a problem is that a Text can have multiple Values, as seen in your XML above. You could use this by adding another entity called Value, but I would probably solve it by adding the attributes "value" and "type" to the Text entity directly. (You could then use "value" as a second sort key when printing out a page.
Check out these links:
http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/CoreData/
http://developer.apple.com/cocoa/coredatatutorial/index.html (for regular Cocoa, but the same principles hold so this should help)