Selecting selected names on a a custom select list within InstantKB



I am busy with adanced workflow interaction through the API. And creating some helper functions to make this happen.
Since there's not a lot posted here, as part of the final solution, I will post small code sample snippets. Starting with reading a custom field of type Pick List (Check box list).

public List<string> GetSelectedPickListNames(InstantASP.InstantKB.Components.Ticket ticket, string customField)
{
var customFields = ticket.CustomFields[customField].Split(',');
var templateDetails = InstantASP.Common.Business.Fields.SelectFields(EnumApplication.InstantKB).FilterById(146);
var listValues = InstantASP.Common.Business.PickListValues.SelectPickListValues(templateDetails.PickListID);
return customFields.Select(role => listValues.FilterById(int.Parse(role)).Name).ToList();
}


usage for Example: 

var selectedNames = GetSelectedPIckListNames(ticket, "CustomField_146");

Code on how to select ticket(s) can be found in another post.

 Sjef van Leeuwen | Lead Developer | Oxford Computer Group BeNeLux

www.oxfordcomputergroup.nl | Expertise in Identity & Access Management


InstantKB Question

Thanks again Sjef. I appreciate you taking the time to share. Hopefully this may help someone :)

http://www.instantasp.co.uk/images/line.gif
Kindest Regards,

Ryan Healey



ryan@instantasp.co.uk
www.instantasp.co.uk
Blog | Community | Docs

http://www.instantasp.co.uk/core/assets/images/email/facebook.png http://www.instantasp.co.uk/core/assets/images/email/twitter.png http://www.instantasp.co.uk/core/assets/images/email/google.png http://www.instantasp.co.uk/core/assets/images/email/linkedin.png

Whoops....

var templateDetails = InstantASP.Common.Business.Fields.SelectFields(EnumApplication.InstantKB).FilterById(146);


should be

var templateDetails = InstantASP.Common.Business.Fields.SelectFields(EnumApplication.InstantKB).FilterByTableName(customField);


 Sjef van Leeuwen | Lead Developer | Oxford Computer Group BeNeLux

www.oxfordcomputergroup.nl | Expertise in Identity & Access Management


GO

Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....







InstantASP Forums


Search