Go Back   CHECKBOX® Online Community > Checkbox® > CHECKBOX® Developer Kit

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-01-2008, 05:58 PM
Paayaa Paayaa is offline
Junior Member
 
Join Date: Jan 2008
Posts: 7
Question Get Survey ID under a folder

Hi there,
I created a folder named "CF Templates". Under this folder I have (for now) two Surveys that I want to use them as Template. How can get list of Surveys (probably Survey Name and ID) under a folder using API Kit.

Thanks
Reply With Quote
  #2 (permalink)  
Old 02-05-2008, 09:32 AM
ncushing ncushing is offline
Administrator
 
Join Date: Mar 2007
Location: Prezza Technologies
Posts: 171
Default

Hello Payaa,

I see that you've entered a support ticket for this issue as well, but I'll answer it here so the answer is available to other developer kit users.

To get a list of surveys in a folder, you will want to use the GetAvailableTemplatesAndFolders(...) method of the ResponseTemplateManager.

Here is the method prototype...
Code:
public static DataSet GetAvailableTemplatesAndFolders(FormFolder folder, int pagesize, int page, string filterField, string filterText, string sortField, bool descending, params string[] permissions)
The DataSet that is returned contains one table with columns that match the columns in the ckbx_TemplatesAndFolders view in the database. Rows for surveys have an ItemType field equal to 'Form' and rows for folder have an ItemType field equal to 'Folder'. In both cases, the ID of the form/folder is stored in the ItemID field and the name of the form/folder is stored in the ItemName field.

Code:
using Checkbox.Users;
using Checkbox.Forms;

//Step 1:  Response templates are secured, so a valid user context must be established

//Initialize UserManager, only needs to done once per application lifetime
UserManager.Initialize();

//Login a user with permission to Edit or Take surveys
if(UserManager.AuthenticateUser([USERNAME], [PASSWORD]) == null)
{
   throw new Exception("User not authenticated!");
}

int folderId = [ID OF FOLDER];

//First, get the folder (4.5 API method will accept folderId)
FormFolder folder = new FormFolder();
folder.Load(folderId);

//Now load the folders
DataSet ds = ResponseTemplateManager.GetAvailableTemplatesAndFolders(
folder,                //folder to search in
-1,                    //number of results per "page of results".  Pass -1 for no paging of results
-1,                    //"page" of results to get.  Pass -1 for no paging
null,                  //DB field to filter results on.  Pass null for no filtering
null,                  //Value of filter.  Pas null for no filtering
"ItemName",       //DB field to use for sorting results, pass null for no filtering
false,                //Sort order.  Pass true for descending order
"Form.Edit", "Form.Fill")   //Permissions to check for currently logged-in user


//Get the rows for surveys
DataRow[] surveyRows = ds.Tables[0].Select("ItemType = 'Form'");
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 05:22 PM.


Search Engine Friendly URLs by vBSEO 3.0.0 RC8