Forms Service API - How do I get all forms in the system created by a specific user?

Vote:
 

Hi!

I need to get alla forms in the system created by a specific user.

Right now I am using "IFormRepository" and getting all the forms with "GetFormsInfo()", this returns all the forms in the system but I need all forms created by a specific user.

Is there a way to do this?

The data returned by "GetFormsInfo()" does not contain any info about which user created the form.

#216306
Feb 03, 2020 12:48
Vote:
 

Hi,

Depending on what you wanted to do with the forms when you've found them, you could just treat them the same way as any other piece of content. Rather than using IFormRepository, you could perhaps get all instances of "FormContainerBlock" and filter them by creator (which is a property of IChangeTrackable) like this:

var contentModelUsage = ServiceLocator.Current.GetInstance<IContentModelUsage>();
var contentTypeRepo = ServiceLocator.Current.GetInstance<IContentTypeRepository>();
var templateType = contentTypeRepo.Load("FormContainerBlock");

var allForms = contentModelUsage.ListContentOfContentType(templateType).Select(x => contentLoader.Get<IContentData>(x.ContentLink, new CultureInfo(x.LanguageBranch)));
var bobsForms = allForms.Where(x => (x as IChangeTrackable).CreatedBy.Equals("Bob"));
#216308
Feb 03, 2020 15:09
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.