8/18/2025 1:27:27 AM
|
|
slxdeveloper.com Community Forums |
|
|
|
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
Forum to discuss the use of the SalesLogix Web Platform, Client and Customer Portals, and the Application Architect (For version 7.2 and higher only). View the code of conduct for posting guidelines.
|
|
|
|
Insert Opp Contact with Entity model
Posted: 22 Apr 09 4:00 PM
|
I have a custom page to filter only contacts that belong to the opp parent account. A datagrid is displayed, the user clicks on the contact they want to choose and the id is returned to the "GridView1_SelectedIndexChanging" procedure. Is it possible to insert the contactid using the entity model?
I had coded an insert that works but would like to use the entity model.. I am trying this although I know it won't work: string contid = GridView1.DataKeys[rowIndex].Value.ToString(); Sage.Entity.Interfaces.IOpportunity opp = this.GetParentEntity() as Sage.Entity.Interfaces.IOpportunity; IOpportunityContact oppcon = Sage.Platform.EntityFactory.Create(); oppcon.Opportunity = opp; oppcon.Contact = contid; oppcon.Save(); Of course I get 'Cannot implicitly convert type 'string' to 'Sage.Entity.Interfaces.IContact' on this line > oppcon.Contact = contid;
So how can I insert the contactid I have returned from the gridview into the oppcontact entity? Is this possible? I know it is looking for an object but am not quite sure how to give it what it wants.. thanks
|
|
|
|
Re: Insert Opp Contact with Entity model
Posted: 22 Apr 09 5:39 PM
|
Steve, You're trying to set the contact object to an ID. You need one more step to get the contact object:
oppcon.Contact = Sage.Platform.EntityFactory.GetById(contid.ToString());
This returns a contact object which is what the oppcontact entity is looking for. |
|
|
|
Re: Insert Opp Contact with Entity model
Posted: 23 Apr 09 7:38 AM
|
Thanks for pointing me in the right direction Mike - actually this is what worked: oppcon.Contact = Sage.Platform.EntityFactory.GetById(contid);
|
|
|
|
Re: Insert Opp Contact with Entity model
Posted: 23 Apr 09 8:39 AM
|
I have a somewhat related question.. I am calling an insert child dialog action from the (+) button on the insert opp contact grid. A datagrid with all contacts for the parent account show up, user clicks one and the insert is made with the entity model. I have two problems I am trying to get around: 1. This does not work when called from the insert opp screen as the oppID doesn't exist yet.. Is there a way to get around this? 2. Closing the insert screen - The flow goes like this - user clicks the grid and that fire the insert on the SelectedIndexChanging event. If I then close the screen with the X in the corner, the grid on the opp contacts tab refreshes and shows the new contact. I tried closing the screen with DialogService.CloseEventHappened(sender, e); after the insert. I also tried firing it from the SelectedIndexChanged event with the same results - the form closes but doesn't refresh the grid. Then I tried firing from a button click - this closes the screen and refreshes the grid.. Can I get the screen to close without an extra button click and still refresh the grid? Thanks |
|
|
|
Re: Insert Opp Contact with Entity model
Posted: 23 Apr 09 10:17 AM
|
Steve, Glad you got it working. I'm always on the paranoid side when passing IDs around, so I'll almost always put that ToString() on the end in my code.
On your first issue, you should be able to get it working. Even though the opp is not yet created in the DB, it is created in memory. The insert child dialog will more or less do the following: - Create an OppContact entity - Set the contact to the selected contact - Do an Opp.Contacts.Add passing in the oppcontact entity from above. Filtering the contacts will only work if you have an account in context already. You can see if you have an account by calling the GetParentEntity function when you enter the form.
On your 2nd issue, you'll probably need to manually call the refresher service to refresh your grid before you close the dialog. Here's the stock code from the oppcontacts screen:
if (PageWorkItem != null) { Sage.Platform.WebPortal.Services.IPanelRefreshService refresher = PageWorkItem.Services.Get(); if (refresher != null) { refresher.RefreshAll(); } else { Response.Redirect(Request.Url.ToString()); } }
|
|
|
| |
|
You can
subscribe to receive a daily forum digest in your
user profile. View the site code
of conduct for posting guidelines.
Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
|
|
|
|
|
|
|
|