Xpages Calendar View - calendar

on my one of my XPages i have to use Calendar view. There is a Notes View. I will use it as XPages Data source then the calendar will Show the data as weekly, Daily and monthly.
is there any sample, suggestion?
I found this but there is no sample code or the way how to do?
https://www.openntf.org/internal/home.nsf/project.xsp?documentId=E78FED69C5D805E0862576C50050D88B
Regards
C.A.

Download an ExtLib version from OpenNTF and get the example database "XPagesExt.nsf" from "ExtensionLibraryOpenNTF-901v....zip" file. XPages "DWA_iNotesRest.xsp" and "DWA_LocalCalendarView.xsp" show you how to create a calendar in XPages.
You can find another good example in template "TeamRoom (9)". Create a new database on your server based on this template
and have a look at XPage "calendar" with included custom control "calendarView".
Update
I created a simple example:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view
xmlns:xp="http://www.ibm.com/xsp/core"
xmlns:xe="http://www.ibm.com/xsp/coreex">
<xe:restService
id="restService1"
pathInfo="/inoteslegacyjson"
preventDojoStore="false">
<xe:this.service>
<xe:calendarJsonLegacyService
viewName="calendar"
contentType="text/plain"
colCalendarDate="StartDateTime"
colEndTime="EndDateTime"
colSubject="Subject"
colChair="Chair">
</xe:calendarJsonLegacyService>
</xe:this.service>
</xe:restService>
<xe:calendarView
id="calendarView1"
type="W"
storeComponentId="restService1"
style="width:100%">
</xe:calendarView>
</xp:view>
The view is named "calendar"
View's first sorted(!) column has to be the start date/time.
Its programmatic column name is matched to colCalendarDate.
The other three columns are matched the same way.

Related

How to handle incremental fetches from Salesfore and Database Component

I have a salesforce query which returns contact information. I need to save the data in 2 tables. In the first table I have to store some metadata about the contacts in an intermediate state. I then get the auto-generated metadata table ID from the metadata saved and apply it to every contact. I then have to save the contact data into a database table and then finally update the contacts metadata to its final state. The problem is that there is a lot of data so I have to include a fetch size when performing this process. What I want to achieve should be something like this, please note this is only what I am looking to achieve. How can I know that the fetch contacts is complete, so that I can save the final state? How can I structure the flow for transactions?
Ideally, I would like to pass the ConsumerIterator to a Java component where I can easily control the process. Can I pass a reference of the ConsumerIterator to a Java component for example? If I can how can I do so?
<sfdc:query fetchSize="100" config-ref="sfdc-connector"
query="dsql:SELECT Id, Account.Id,
Account.Name, Account.PersonEmail, Account.LastName From Contact" />
dw:transform-message metadata:id="d1f6ab4f-4b40-4e30-ae" doc:name="trnsfm">
<enricher target="variable:metaInfo">
<flow-refname="getContactMetadata"/>
</enricher>
<dw:set-payload><![CDATA[%dw 1.0
.//Rest of transformer
<db:insert config-ref="MySQL_Configuration" doc:name="Save Metatdata">
...
</db:insert>
<db:insert config-ref="MySQL_Configuration" doc:name="Save contacts">
....
<db:insert>
<db:insert config-ref="MySQL_Configuration" doc:name="Update Metadata
Final State">
....
<db:insert>
</flow>
Problem Solved. I wrote a Java Component, implementing Callable and grabbed the ConsumerIterator. I then was able to use the iterator to obtain items in fetchSize. I then used Spring Jdbc since the data model is simple enough to transactionally save the data

Posting date values in REST service will not create date fields in the Domino back end

I'm creating an AngularJS HTML app using Domino in the back-end. The communication is 100% rest-based via DDS
When I send date values they don't get converted to date items on the Domino document. The values are always stored as strings
I have tried various formats on the date string with no luck
Does anyone know is this is even possible with the Domino Data Services ?
I'm using Angulars $http service with the PATCH method to update changed values only
It is possible to store/ update a data in a document using Domino Data Services.
To get it to work you need to send the date as a string in ISO 8601 Extended format. That's the format that the toISOString() function returns in JavaScript for a Date object. On the form that you're trying to create or update, you'll need to have that field added as a Date/Time field. Adding the computewithform parameter to the request isn't required.
Here's a sample JSON object that, when send as a POST or PATCH request to DDS, will create/ update the LastVisit field as a DateTime field (assuming that field is on the form).
{
"FirstName":"Barney",
"LastName":"Bloomberg",
"LastVisit" : "2013-12-21T12:18:18Z"
}
The field name in the json string must be EXACTLY as on the form.
I had the similar problem where I had a field called 'TTL' on the form but my json generated by API using a class the field was named 'ttl'.
This resulted in a String as value for the date field, not a date.
This works :-)
I have extended the sample that I used in my presentation in the following way:
Added a field "WakeupTime" on the form. Set it to Date/Time, and select to display date and time. The sample output is 08-01-2016 16:11:42.
So reading the sample data using this url:
.../json.nsf/api/data/documents/unid/33735D0BCE799E01C1257CC3007A7221
I get something like this back:
{
"#href": "/demo/json.nsf/api/data/documents/unid/33735D0BCE799E01C1257CC3007A7221",
"#unid": "33735D0BCE799E01C1257CC3007A7221",
"#noteid": "902",
"#created": "2014-04-23T22:17:26Z",
"#modified": "2016-01-08T15:09:57Z",
"#authors": [
"Anonymous",
"CN=John Dalsgaard/O=D-D"
],
"#form": "Person",
"Unid": "33735D0BCE799E01C1257CC3007A7221",
"Key": "33735D0BCE799E01C1257CC3007A7221",
"Name": "Peter Hansen",
"Email": "ph#mail.dk",
"YearBorn": 1955,
"WakeupTime": "2016-08-01T05:33:10Z"
}
Important! - this gives me the exact format that I need to use for the WakeupTime field!
So if I then post a PATCH back with select fields:
{
"Email":"peter.hansen#mail.dk",
"YearBorn":1953,
"WakeupTime":"2016-01-08T05:33:40Z"
}
... and re-read the data then the fields are updated. And if I check in the Notes client I can see that the field is a date/time field :-)
Same happens if I create a new entry/document - the field is still the right type.
You have to be very aware of how you handle timezones though! The data are transferred as GMT :-)

"Related Content" stored in which object / How to create "Related Content" records from Apex

If you navigate to account/contact/custom object we do have a related list "related content" (if content is enabled and related list is added to page layout).
My question is were are these "related content" records stored? in which object?
Using apex I'm able to upload file to content version, but not able to create or find the object which stores the "related content" information.
UPDATE
Tried to create a link to show up in "related content" section of account, but no success. Got error " Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, You cannot create a link for this type of entity through the api: [LinkedEntityId]"
Any idea?
ContentVersion cv = new ContentVersion(
versionData = EncodingUtil.Base64Decode(base64BlobValue),
Title = fileName,
PathOnClient = '/'+fileName,
FirstPublishLocationId = '058900000009KcL'
);
insert cv;
//fetch ContentDocumentId
cv = [Select Id,ContentDocumentId from ContentVersion where Id = :cv.Id];
insert new ContentDocumentLink(LinkedEntityId=parentId,ContentDocumentId=cv.ContentDocumentId,ShareType='V');
** USE CASE **
The use case is to allow user to attach content right from object detail page for eg say Account will have button say Attach Content, this will bring upload content page, once uploaded (i will create contentversion records - this is happening perfectly, no errors) and then I need to relate the uploaded content to account (from which request orginated) ie create "related content" records (here I'm facing difficulty, trying to create contentdocumentlink records but its erroring out).
The use case is just one click to attach content to account or opportunity instead of long current process were user goes to content, uploads there first and then comes back to account/opty and searches content again, and then attaches it to account/contact.
As you know the content is stored in the ContentDocument object and the links are stored in the ContentDocumentLink table.
I find that the http://workbench.developerforce.com really useful for figuring out these kinds of relationships.
See the ContentDocumentLink specification in the user docs, LinkedEntityId represents:
ID of the linked object. Can include Chatter users, groups, records
(any that support Chatter feed tracking including custom objects),
and Salesforce CRM Content libraries.
I'm thinking that based on that explanation, you can only create the ContentDocumentLink for Chatter based object fields, not for regular sObject records or custom sobjects, etc.

SalesForce Bulk API: Relationship between custom object and Account

I have a custom object in SalesForce called Deal, which is a child of the built-in Account object. I am trying to use the Bulk XML API to upload a batch of records, but I can't seem to figure out how to specify this relationship correctly. From the documentation it says that you should reference a custom object's relationships like so:
<Relationship__r>
<sObject>
<some_indexed_field>#####</some_indexed_field>
</sObject>
</Relationship__r>
If you have any idea how to specify a relationship to the Account object from a custom object I'd really appreciate it.
Added
The Deal object has the following 2 fields:
DealID
API Name - DealID__c
Data Type - Text(255)(External ID)(Unique Case Sensitive)
Account
API Name - Account__c
Data Type - Master-Detail(Account)
Request XML:
<Account__r>
<sObject>
<ID>0013000000kcWpfAAE</ID>
</sObject>
</Account__r>
Result XML:
<result>
<errors>
<message>Field name provided, Id is not an External ID or indexed field for Account</message>
<statusCode>INVALID_FIELD</statusCode>
</errors>
<success>false</success>
<created>false</created>
</result>
There appears to be a bug and you have to strip out all whitespace and newlines when dealing with reference objects.
Check out:
http://success.salesforce.com/ideaview?id=08730000000ITQ7AAO
From the docs
<RelationshipName>
<sObject>
<IndexedFieldName>rwilliams#salesforcesample.com</IndexedFieldName>
</sObject>
Everything looks good, but instead of using "ID" for the Indexed Field Name, you need to use "Account__c". That should take care of your issue.

Web2py: How should I display an uploaded image that is stored in a database?

Is there a web2py way of displaying images from a database table?
Example:
The model:
db.define_table=('images',Field('picture', 'upload' ))
The controller:
def somefunction(): to get the image.
How exactly should I "read" a picture from the database?
The view:
<img src="{{somefunction}}" />
As is, your model will not store the image in the database -- instead, it will store the image on the filesystem, with its new filename stored in the database (in the 'picture' field). If you want to store the image itself in the database, use the following:
db.define_table('images',
Field('picture', 'upload', uploadfield='picture_file')
Field('picture_file', 'blob'))
Whether you store the images on the filesystem or in the database, you can use the same method to retrieve them. The 'welcome' scaffolding application includes the following download() action in the default.py controller:
def download():
return response.download(request, db)
To retrieve an image, just do something like:
<img src="{{=URL('default', 'download', args=picture_name)}}" />
where picture_name is the value stored in the 'picture' field of the 'images' table for the particular image you want to retrieve.
For more details, see here and here.
If you need further help, try asking on the mailing list.
Alternatively, if you use web2py's default way of uploading images as files, you can use:
In models:
db.define_table('images',Field('picture','upload'))
In controllers:
def somefunction():
pic = db(db.images).select().first().picture #select first picture
return dict(pic=pic)
And in the default/somefunction.html view:
{{extend 'layout.html'}}
<img src="{{=URL( 'download', args=pic)}}" />
I know this is a while after the original question but thought it might be useful as it took me a while to figure out.

Resources