Progress will discontinue Telerik Platform on May 10th, 2018. Learn more

Associating Files with Data Items

Associating Files with Data Items

If you have already uploaded a file and have its ID, you can assign it to a content type items as a value. The Telerik Platform portal automatically expands File IDs of pictures and displays a thumbnail in the details pane.

Create Associations

Creating association to a file is as simple as setting the desired file field value of the content type to be the ID of a file.

public void createAssociation(EverliveApp app, UUID bookId, UUID pictureId) {
    Book updateObject = new Book();
    updateObject.Picture = pictureId;
    app.workWith().data(Book.class).updateById(bookId, updateObject).executeAsync();
}

Remove Associations

Deleting an item from the database does not unlink it from the items that are associated with it. In order to remove the association an additional request has to be made.

Single Association

public void deleteAssociation(EverliveApp app, UUID bookId) {
    Book updateObject = new Book();
    updateObject.Picture = null;
    app.workWith().data(Book.class).update(bookId, updateObject).executeSync();
}

Note: Instead of using an instance of Activity, you can use the UpdateObject class as shown here

All Associations

In order to delete all references to a given file you will need to make a request in the content type. The example below uses LINQ expression to filter the items associating the file. The same thing can be using any other filtering method described here.

public void updateActivitiesByFilter(EverliveApp app, UUID pictureId)
{
    Book updateObject = new Book();
    updateObject.Picture = null;
    app.workWith().data(Book.class).update(updateObject).
        where(new ValueCondition("Picture", pictureId, ValueConditionOperator.EqualTo).executeSync();
}
Contact us: +1-888-365-2779
sales@telerik.com
Copyright © 2016-2017, Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.