02-07-2011 02:42 PM
Hi All,
I'm having a hard time trying to do this.
My plugin needs to create a new opportunity and set it's access level to "Limited Access"
I know that the only way to do that is to set the Opportunity accessors list do a specific user (or users).
From the SDK I found the Opportunities.SetAccessors function
OK, I already have the MutableEntities.Accessor list (I have used this list to set the contact's access level), but have no idea on how to get the mutableEntity for the opportunity i'm creating (actualy the opportunity is already created).
Does anyone have any idea on how to do that ?
thanks in advance
Flavio Frate
ACT!Brasil
02-08-2011 06:04 AM
Hello Flavio,
Not sure if I've posted this elsewhere in this subforum, but I have an example of setting the access level of the current opportunity for a particular team. Hope this helps:
Opportunity o = _ActApp.ApplicationState.CurrentOpportunity;
if (o.CanChangeAccessType)
{
OpportunityManager oppman = new OpportunityManager(_ActApp.ActFramework);
Accessor[] AccessList = new Accessor[1];
Accessor AdminTeam = oppman.GetAccessorAdminTeam();
Accessor Team2 = oppman.GetCurrentUserAccessor();
AccessList[0] = AdminTeam;
oppman.SetAccessors(o, AccessList);
}
02-08-2011 06:04 AM
Hello Flavio,
Not sure if I've posted this elsewhere in this subforum, but I have an example of setting the access level of the current opportunity for a particular team. Hope this helps:
Opportunity o = _ActApp.ApplicationState.CurrentOpportunity;
if (o.CanChangeAccessType)
{
OpportunityManager oppman = new OpportunityManager(_ActApp.ActFramework);
Accessor[] AccessList = new Accessor[1];
Accessor AdminTeam = oppman.GetAccessorAdminTeam();
Accessor Team2 = oppman.GetCurrentUserAccessor();
AccessList[0] = AdminTeam;
oppman.SetAccessors(o, AccessList);
}
02-08-2011 06:38 AM
Hello Matthew,
Thanks for your answer.
Unfortunatelly the code does not run, it returns an exception without further information. See bellow:
System.ApplicationException was caught Message="error" Source="Act.Framework" StackTrace: at Act.Framework.MutableEntities.MutableAccessorDB`1.SetAccessors(T t, Accessor[] accessors) at Act.Framework.Opportunities.OpportunityManager.SetAccessors(MutableEntity mutableEntity, Accessor[] accessors) at AtivaCliente.clsAtivaContato.CriaOportunidade(Contact ct) in C:\Arquivos de Clientes\Advis\AtivaCliente\clsAtivaContato.vb:line 436
Do you think I may be missing somenthing else ?
Flavio
ACT!Brasil
02-08-2011 06:41 AM
I forgot to mention in my last post:
I'm using ACT!2011...
Flavio Frate
ACT!Brasil
02-08-2011 07:09 AM
Hi Matthew,
I got it !
The problem was not your code, it works like a charm.
Actually the opportunity was created but not updated !
My code was creating the opportunity, filling all pertinent fields, trying to set thee access level and then updating then opportunity.
The trick was the exception messsage error without explanation. Looking better, I found that at the SetAccessors time, the opportunity did not have Creat Date nor Edit date.
So the update solved the problem.
Thanks again for your help.
Flavio Frate
ACT!Brasil