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!
|
|
Insert Opportunity question
Posted: 07 Apr 09 6:41 PM
|
On the insert opp screen, when a user adds a product on insert, I need to access the accountid from the top portion of the insert opp screen on the insert opp product screen launched from the plus button (add opportunity product) on the insert opp screen. Is there a way to get the accountid on the insert opp product screen? |
|
|
|
Re: Insert Opportunity question
Posted: 08 Apr 09 9:15 AM
|
One way that we have gotten around similar scenarios is by putting a hidden field on the screen containing the ID (you would derive it from lveAccount). This is a very common solution for us to have IDs not inherently available on the form. |
|
|
|
Re: Insert Opportunity question
Posted: 08 Apr 09 9:24 AM
|
How would I get the value from the lveAccount on insert opp screen to the Add opp product screen? This is my disconnect..
|
|
|
|
Re: Insert Opportunity question
Posted: 08 Apr 09 9:40 AM
|
Ahh - I see...you haven't actually written anything to the DB yet. Unfortunately I don't have an answer for you. In our industry we've had to scrap nearly the entire Opportunity process (since we don't actually selling anything) and design our own...including a new Insert Opportunity screen. |
|
|
| |
|
Re: Insert Opportunity question
Posted: 08 Apr 09 1:48 PM
|
Thanks Ryan.. I am still not quite out of the woods.. so this is the magic: IMyParentEntity myparent = form.WorkItem.Services.Get().GetEntity() as IMyParentEntity;
In the context of the Insert Opp Product smartpart, how would I get the accountid from the lueAccount on the insert opp form? |
|
|
|
Re: Insert Opportunity question
Posted: 08 Apr 09 1:58 PM
|
First of all, I am assuming that this is in a Code Snippet Action.
Basically you'd do something like this and it would likely work just fine (not tested or anything)
// get the current opp bound to the Insert page IOpportunity opportunity = form.WorkItem.Services.Get().GetEntity() as IOpportunity; // now you can reference the account linked to the opp (that was selected in the lookup) IAccount account = opportunity.Account; form.labelControl.Text = account.Id.ToString(); // etc
Does that make sense? |
|
|
|
Re: Insert Opportunity question
Posted: 08 Apr 09 2:07 PM
|
Also, to point out Steve,
The "how" all goes back to what the entity is for the form itself. Thinking about your situation a bit (I don't have a SLX system where I am at), the form you're doing this on is probably already an opp form. If that is the case there is no need to get the parent, but just the current entity:
IOpportunity opp = form.CurrentEntity as IOpportunity; string accid = opp.Account.Id.ToString();
The point is, once you get a reference to the opp entity itself, you just access the selected account from the Account relationship property. That should work fine.
-Ryan |
|
|
|
Re: Insert Opportunity question
Posted: 08 Apr 09 4:24 PM
|
Ryan, the add opp product screen ships as a custom screen found under suppport files - so I am not calling from a Code Snippet Acction - I am trying to put the code in the addopportunityproduct.ascx.cs.
The first place I tried it is in the pageload event. On this line: IOpportunity oppo = form.WorkItem.Services.Get().GetEntity() as IOpportunity; I get the error: Error 40 The name 'form' does not exist in the current context
I am assuming it is because it is not in a Code Snippet Action.. any thoughts? |
|
|
|
Re: Insert Opportunity question
Posted: 08 Apr 09 4:55 PM
|
Ah. That is right. In that case you will use:
Sage.Entity.Interfaces.IOpportunity opp = this.GetParentEntity() as Sage.Entity.Interfaces.IOpportunity; // opp.Account; |
|
|
|
Re: Insert Opportunity question
Posted: 08 Apr 09 7:14 PM
|
Got it. Thanks! It bombed in the onload event but is working like a charm in the Prerender event. thanks for the explaination Ryan. I am going to take a stab at a similar operation in a code snip actions so your previous explaination won't go to waste. |
|
|
|