+ Start a Discussion
muni u 5muni u 5 

how to write test class for service resource skill object in field service lightning

how to write test class for service resource skill object in field service lightning?Below is my code

    //creating a ServiceResource
        ServiceResource objServiceResource=new ServiceResource();
        objServiceResource.Name='Test Resource';
        insert objServiceResource;       
 //creating a ServiceResourceSkill
        insert objServiceResourceSkill;

this is the test obj i have created.I am unable to understand how to give 'SkillId' for the ServiceResourceSkill 
Can any one please help me.
Deepali KulshresthaDeepali Kulshrestha
Hi muni ,

For SkillId, you have to give the reference of the ID of the skill.

Create an object of skill and give the Id in  SkillId.

Go through with this link, it will help you



I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha.
muni u 5muni u 5
Hi Deepali,
Thanks for the reference and for providing the links.
Actuallly I have tried to Create a 'Skill' in developerConsole.But it throwed an error like "DML operation Insert not allowed on Skill".
And in the testclass aslo i am unablke to create the skill.Do u have any idea??

Thanks and Regards,
muni u 5muni u 5
User-added image

When I have tried to create a Skill from developer console.i got this error
muni u 5muni u 5
Below is the code wchich I have tried to insert in the Anonymous window/Developer console.

Skill objSkill=new Skill();
insert objSkill;

below is the Error : 

Skill Insert
Zoran Subotic 16Zoran Subotic 16
Has anybody been able to resolve this issue or we need to use rest resource and insert skills from callouts?
I have an external system that is providing us with skills and I want to be able to create a skill in apex of course but I am getting the same error from above...
Pooja Agarwal 31Pooja Agarwal 31
We have encountered the same issue. We are planning to use CLI Data Commands to load Skills using CSV for now. CLI Data load command works fine to Skills object
muni u 5muni u 5
Hi Pooja,
Thankyou for responding for the issue.Any way I have resolved the above issue long time back ago.
Thankyou all for ur responses.
Anurag TejwaniAnurag Tejwani
Hi muni u 5,
How did you solve this issue?
muneeswar umuneeswar u
Hi Anurag, I have stored Skill Id in the custom label and referred that Label in my test class. Regards, Muneeswar