skills assigned

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:

      
                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);
                }

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?

[/foreach (CfgSkillLevel level in person.AgentInfo.SkillLevels)
                {
                    
                    if (level.Skill.Name == "TEST")
                    {
                        person.AgentInfo.SkillLevels.Remove(level);
                        
                        
                    }
                }
person.Save();code]

It’s a standard error because you are trying to remove an object from a collection you are iterating.

https://stackoverflow.com/questions/6177697/c-sharp-collection-was-modified-enumeration-operation-may-not-execute

You need to do something like this instead:

        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();
        }