Asked by:
How do i get team onwershipid in dynamics crm 2013

Question
-
i tried to assign a particular record to a team using plugin.for that i have to pass the teamownerid in the Assignrequest class.but i'm unable to find the teamownerid.could anyone clarify that how to get teamownerid.
hsk srinivas
Wednesday, June 18, 2014 7:01 AM
All replies
-
Hello,
you need to use teamid, please check this sample, if you don't have team id you can query team entity using it's name to get teamid.
Our Website| Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.- Proposed as answer by HIMBAPModerator Wednesday, June 18, 2014 7:21 AM
Wednesday, June 18, 2014 7:21 AMModerator -
how do i get teamid i'm using the js function like
var owner= Xrm.Page.getAttribute("teamid").getValue();
alert(owner);
its getting getValue is undefined or nullreference.
hsk srinivas
Wednesday, June 18, 2014 7:33 AM -
In js you need to use like below
if(Xrm.Page.getAttribute("teamid")!=null && Xrm.Page.getAttribute("teamid").getValue()!=null)
{
var owner= Xrm.Page.getAttribute("teamid").getValue()[0].id;
}
Our Website| Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.Wednesday, June 18, 2014 7:39 AMModerator -
Hi,
If you're planning to retrieve the Team Id using Plugin, you will first need to the fetch the Team Id from CRM using a Query Expression, something like below:
QueryExpression teamQuery = new QueryExpression("team"); ColumnSet teamColumnSet = new ColumnSet("teamid"); teamQuery.ColumnSet = teamColumnSet; teamQuery.Criteria = new FilterExpression(); teamQuery.Criteria.FilterOperator = LogicalOperator.And; teamQuery.Criteria.AddCondition("name", ConditionOperator.Equal, "XYZ"); teamQuery.AddLink("teammembership", "teamid", "teamid").AddLink ("systemuser", "systemuserid", "systemuserid").LinkCriteria.AddCondition("systemuserid", ConditionOperator.Equal, salesRepGuid); EntityCollection teamDetail = service.RetrieveMultiple(teamQuery);
Once you have the Team Id, you can pass that to assign the record to it.
Wednesday, June 18, 2014 7:48 AM -
hi
i tried your code but its not getting anything like alert the js look like
function getOwnerId()
{
debugger;
if(Xrm.Page.getAttribute("teamid")!=null && Xrm.Page.getAttribute("teamid").getValue()!=null)
{
var owner= Xrm.Page.getAttribute("teamid").getValue()[0].id;
alert(owner);
}
}
hsk srinivas
Wednesday, June 18, 2014 8:51 AM -
Thank You.
hsk srinivas
Wednesday, June 18, 2014 8:58 AM -
Are you sure you are using correct field name ??, if you are trying to get ownerid, then it should be ownerid instead of teamid
function getOwnerId()
{
debugger;
if(Xrm.Page.getAttribute("ownerid")!=null && Xrm.Page.getAttribute("ownerid").getValue()!=null)
{
var owner= Xrm.Page.getAttribute("ownerid").getValue()[0].id;
alert(owner);
}
}Our Website| Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.Wednesday, June 18, 2014 8:58 AMModerator -
The field name is teamid only.there is no ownerid
.
hsk srinivas
Wednesday, June 18, 2014 9:05 AM -
Where and how you are calling your js ?
Our Website| Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.Wednesday, June 18, 2014 9:11 AMModerator -
i'm calling js in onload in the form team entity
hsk srinivas
Wednesday, June 18, 2014 9:17 AM -
if you are calling it in Team entity form
you should get it like below
var ownerid=Xrm.Page.data.entity.getId();
Our Website| Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.Wednesday, June 18, 2014 9:26 AMModerator -
I THINK THAT IS USER ID.ITS NOT OWNERID.GETTING ERROR IN PLUGIN THE REQUEST RESOURCE WAS NOT FOUNDED.
hsk srinivas
Wednesday, June 18, 2014 9:34 AM -
You said you are using it in Team form, so Xrm.Page.data.entity.getId() will give you teamid not userid.I don't understand what you are trying to do, if you are doing it in plugin you should follow above link and code provided. What you are trying to achieve through js code then ?? if you could explain your reqirement someone can help you to implement that.
Our Website| Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.Wednesday, June 18, 2014 9:55 AMModerator -
i want to assign a record to a team using plugin.for that passed guid for the team it says that request not found then i go for teamid to get teamid using js.if teamid is get means i want to pass it to plugin.then i want to assign a record to a particular team.
hsk srinivas
Wednesday, June 18, 2014 10:01 AM -
You can't pass parameter from js to plugin, share your code below, what is plugin registeration details ?? when you want to assign your record to team ??
Our Website| Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.Wednesday, June 18, 2014 10:12 AMModerator -
what my requirement is assign record to a team using plugin.for that i'm trying to get teamid using js.if teamid should come i will take that id and paste it to plugin.i'm not passing any param to plugin.below is my code.
if (context.InputParameters.Contains("Target") && (context.InputParameters["Target"]) is Entity) { Entity en = (Entity)context.InputParameters["Target"]; Guid getguid = new Guid("9BB677D7-52F5-E311-870C-D89D6765A2DC"); // here i passed Xrm.Page.data.entity.getId(); assignreq.Assignee = new EntityReference("team", getguid); assignreq.Target = new EntityReference(en.LogicalName, en.Id); AssignResponse assignresponse = (AssignResponse)service.Execute(assignreq); }
but i'm unable to get the teamid.
hsk srinivas
Wednesday, June 18, 2014 10:44 AM -
Hi,
You cannot use Xrm.Page.data.entity.getId() in Plugin; it's strictly JavaScript code. You say you need to assign to a Team, is that a fixed team? Or do you need to change that depending on some criteria, like say the Team to which the current user belongs to, etc?
Either way, you need to retrieve a Team Id using the Query Expression. If you could tell us your business requirement we might be able to assist you better.
Wednesday, June 18, 2014 10:49 AM -
ok.if i assign a record to a team using plugin means i have to retrieve teamid using query expresion.thanks for suggesting the answers. the above code is.i'm not using js in plugin.for your undertstand only pasted that js because pasted that id to guid.
hsk srinivas
Wednesday, June 18, 2014 11:00 AM -
Yes, before you assign a record to a team, you need to get the Team Id. For getting the Team Id, you need to use a query expression to retrieve it unless you have that Team lookup somewhere in the entity itself.Wednesday, June 18, 2014 11:05 AM
-
Thanks for Suggesting...
hsk srinivas
Wednesday, June 18, 2014 11:22 AM -
You need to change Guid getguid = new Guid("9BB677D7-52F5-E311-870C-D89D6765A2DC");
and need to write a retrievemultiple call (assuming you don't have team lookup) to fetch teamid based on it's name or based on some other parameter.
Check this for sample code
Our Website| Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.Wednesday, June 18, 2014 11:36 AMModerator