Community
Showing results for 
Search instead for 
Do you mean 
Reply

Documents tab in Opportunity

Tuned Listener
Posts: 6
Country: USA

Documents tab in Opportunity

Hi!

 

I need information about create an attachement in the documents tab for an opportunity...  

 

Thanks!

 

 

Employee
Posts: 1,163
Country: USA

Re: Documents tab in Opportunity

I had thought there was an overload for create history that accepted an opportunity list, I didn't see it but I believe you can assign a new history to an opportunity like this:

 

History h = ActApp.Actframework.Histories.CreateHistory();

h.OpportunityList = myOppList;

Matthew Wood
Act! SDK Support
Community Moderator
Tuned Listener
Posts: 6
Country: USA

Re: Documents tab in Opportunity

[ Edited ]

Doesn't work..  This is for creating an History with an Attachment...   I'm talking about the Documents Tab.. Where you can add a file or a shortcut..

 

Thanks

Employee
Posts: 1,163
Country: USA

Re: Documents tab in Opportunity

I understand, the documents tab and the items on it are just a type of history (Library Document)

Matthew Wood
Act! SDK Support
Community Moderator
Tuned Listener
Posts: 6
Country: USA

Re: Documents tab in Opportunity

Yes.. It was my misunderstanding.. sorry... 

 

 

Opportunity op = ActFrmwork.Opportunities.CreateOpportunity();
op.Name = Description;
op.UpdateContacts(new Guid[] { new Guid(ContactID) }, new Guid[] { });
op.Update();
Attachment att = ActFrmwork.SupplementalFileManager.CreateAttachment(AttachmentMate.History, @"fullPath", "fileName", false);
HistoryType histType = new HistoryType(SystemHistoryType.Library);
OpportunityList oplist = ActFrmwork.Opportunities.GetOpportunityAsOpportunityList(op);                    
History h = ActFrmwork.Histories.CreateHistory();
h.OpportunityList = oplist;
h.ActivityClearedId = Guid.Empty;
h.HistoryType = histType;
h.StartTime = System.DateTime.Now;
h.EndTime = System.DateTime.Now;
h.Regarding = "a";
h.Details = "";
h.Attachment = att;
h.Update();

 

 

Now i'm getting Unable to insert a history...  at h.update()

 

 

Thanks

 


Tuned Listener
Posts: 6
Country: USA

Re: Documents tab in Opportunity

For debugging purpose.. i try with a Contact instead of an Opportunity... and take a constructor..   and everything works great...  


 

Act.Framework.Contacts.Contact con = ActFrmwork.Contacts.GetMyRecord();
History h = ActFrmwork.Histories.CreateHistory(con, Guid.Empty, histType, false, System.DateTime.Now, System.DateTime.Now, "a", " ", att);

 

 

 

Thanks

Tuned Listener
Posts: 6
Country: USA

Re: Documents tab in Opportunity

And now...  if i use this constructor..

 

 

Attachment att = ActFrmwork.SupplementalFileManager.CreateAttachment(AttachmentMate.History, @"fullFilePath", "fileName", false);
HistoryType histType = new HistoryType(SystemHistoryType.Library);
OpportunityList oplist = ActFrmwork.Opportunities.GetOpportunityAsOpportunityList(op);
Act.Framework.Contacts.Contact con = ActFrmwork.Contacts.GetMyRecord();
Act.Framework.Contacts.ContactList clist = ActFrmwork.Contacts.GetContactAsContactList(con);
                    
History h = ActFrmwork.Histories.CreateHistory(con, op, Guid.Empty, histType, false, System.DateTime.Now, System.DateTime.Now, "a", " ")
h.Attachement = att;
h.Update();
it's work!  but..  i got the file added to the Opportunity and the Contact..  so i have 2 copy of the file...

 

Employee
Posts: 1,163
Country: USA

Re: Documents tab in Opportunity

Alright, so it looks like the issue in your first attempt was that no CreateUser had been assigned, I also believe that'll you'll need to assign the ManageUserID (or you could enter either of these by name). Based on the exception I got trying to run your code sample we'd be violating a foriegn key contraint creating a history that had no contacts associated with it.

 

 

Matthew Wood
Act! SDK Support
Community Moderator
Tuned Listener
Posts: 6
Country: USA

Re: Documents tab in Opportunity

It work!  Like you said, we need to assign the CreateUserID property..   and the ManageUserID is not needed!

 

Thank you very much for your help!