Genesys CTI User Forum
Genesys CTI User Forum => Genesys-related Development => Topic started by: carpio on November 03, 2017, 09:18:08 AM
-
Hello,
does someone know how I can see which skill is assigned?
In person I have not really a link to skills only to skill level but that does not help me further.
Any help would be helpful.
-
Hi,
I'm guessing your are using the PSDK CommApp block, if please see the code sample below:
[code]
CfgPersonQuery q = new CfgPersonQuery();
q.UserName = "Monique";
CfgPerson person = confService.RetrieveObject<CfgPerson>(q);
foreach (CfgSkillLevel level in person.AgentInfo.SkillLevels)
{
String skill_name = level.Skill.Name;
log.Debug("SkillName: " + skill_name + " Value: " + level.Level);
}[/code]
-
super thank you a lot
-
Im now trying to remove some skills and skill is also removed but I get exception
collection was modified enumeration operation may not execute
Does someone know this exception and what is causing this?
[code][/foreach (CfgSkillLevel level in person.AgentInfo.SkillLevels)
{
if (level.Skill.Name == "TEST")
{
person.AgentInfo.SkillLevels.Remove(level);
}
}
person.Save();code][/code]
-
It's a standard error because you are trying to remove an object from a collection you are iterating.
[url=https://stackoverflow.com/questions/6177697/c-sharp-collection-was-modified-enumeration-operation-may-not-execute]https://stackoverflow.com/questions/6177697/c-sharp-collection-was-modified-enumeration-operation-may-not-execute[/url]
You need to do something like this instead:
[code] CfgSkillLevel skillToRemove = null;
foreach (CfgSkillLevel level in person.AgentInfo.SkillLevels)
{
if (level.Skill.Name == "MySkill")
{
skillToRemove = level;
break;
}
}
if (skillToRemove != null)
{
person.AgentInfo.SkillLevels.Remove(skillToRemove);
person.Save();
}[/code]