Showing posts with label API. Show all posts
Showing posts with label API. Show all posts

Wednesday, April 10, 2013

Link & Unlink Objects from Folders

How often have you created an object and forgotten to link it to a folder. What typically happens in a situation like this is, the object get linked to the default folder of the user with which you created the object with [You can find the default folder of a user with the default_folder attribute of the dm_user object].

All it takes to link an object to a new folder is three simple steps with API Commands:

1. Link the object to the new [desired] folder. we do this first because its not possible to unlink an object without it having another link.
2. Unlink the object from the old folder.
3. Save the changes, otherwise the whole operation will have no effect.
__________________________________________________________________________________
 
Here is an Example:

1. Link to a new folder:
   link,c,<r_object_d>,/Objects
Where,
 r_object_id is the Object ID of the object to be linked
 /Objects is the folder
 
2. Unlink the object from the old folder:
   unlink,c,<r_object_id1>,<r_object_id2>
Where,
 r_object_id1 is the Object ID of the object to be unlinked
 r_object_id2 is the Object ID of the folder to be unlinked

3. Save the operation
   save,c,<r_object_id>
Where,
 r_object_id is the Object ID of the object that we just Linked and Unlinked.

Wednesday, January 9, 2013

DQL to API

Sometimes, all you have, is access to DA no other tool, and want to run some queries it can be very painful.
There is no way to execute multiple DQLs through DA unlike API commands.

Were you ever stuck in such a situation, well, don't waste your time trying. Just frame your DQLs to do the job, convert your DQL to API commands.


Step1: Frame the DQL:
Let me give two examples as the APIs for them will correspondingly change.

1. CREATE dm_group object SET group_name = 'abc'
2. UPDATE dm_group object SET description = 'abc group' WHERE group_name = 'abc'


If we had to run the above two queries on DA, we would have to run each one at a time. By converting these DQLs into APIs, it is possible to run them in one go. here is what we do:

Step2: Convert DQL to API
Just prefix the DQLs with the following API commands accordingly:
execquery,c,0 [or] execquery,c,F
execquery,c,1 [or] execquery,c,T

Hence our DQLs will look like this:
1. execquery,c,1,CREATE dm_group object SET group_name = 'abc'
2. execquery,c,0,UPDATE dm_group object SET description = 'abc group' WHERE group_name = 'abc'

NOTE: The parameter "1" or "T" in the API command signifies that the action being performed will create a new instance of an object in the repository, so all CREATE DQLs when converted to APIs. For all other Select or UPDATE operations the Parameter value "0" or "F" should be used.

Once the APIs are ready, you can run them in the API editor by choosing the "Script (multi-line) Entry" in the editor which allows execution of multiple API commands.