function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Anu YadavAnu Yadav 

Assign the new user to one of the territories by inserting into the UserTerritory object in Test class

Hi,

I m trying write a test class in which i have to Assign the new user to one of the territories by inserting into the UserTerritory object .
I have created a dummy user and dummy territory. Unable to perform the same for UserTerritory.
i m getting error as DML not allowed on UserTerritory. It can be solved by applying (SeeAllData=true) but it os not the correct way.

Please help.
Thanks.
Roshni RahulRoshni Rahul
Hi Anu,

just go through the links below

https://success.salesforce.com/answers?id=90630000000h92hAAA
http://salesforce.stackexchange.com/questions/14530/create-user-with-territory-for-runas-in-test-method (https://success.salesforce.com/answers?id=90630000000h92hAAA)


Regards,
Roshni