Thanks also to Jose for jumping in. I appreciate both of you guys.
Hi. Can anyone tell me how to create a new UD11 row from within a BPM using custom code?
You can use the business objects for UD11 or update the database directly Since UD11 has no business logic updating it directly isn't much of an issue unless you have a BPM that you would like to fire.
Jim Kinneman
using (var txscope = IceDataContext.CreateDefaultTransactionScope())
{
var NewUD11 = new Ice.Tables.UD11();
NewUD11.Company = Session.CompanyID;
NewUD11.Key1 = someValue.ToString();
......
// commit changes
Db.Validate(NewUD11);
txscope.Complete();
}
Jim Kinneman
Encompass Solutions, Inc
Although you can use the direct to DB as Jim stated, remember that it won't hit BPMs if you do it that way. So always try to use the business object as he first suggested
Jose C Gomez
Software Engineer
T: 904.469.1524 mobile
Quis custodiet ipsos custodes?
On Tue, Jun 23, 2015 at 2:19 PM, jckinneman@... [vantage] <vantage@yahoogroups.com> wrote:Â<div> <p>You can use the business objects for UD11 or update the database directly Since UD11 has no business logic updating it directly isn't much of an issue unless you have a BPM that you would like to fire.</p><div><br></div><div><div>using (var txscope = IceDataContext.CreateDefaultTransactionScope())</div><div>{</div></div><div><div><span style="white-space:pre-wrap;"> </span>var NewUD11 = new Ice.Tables.UD11();</div><div><span style="white-space:pre-wrap;"> </span>NewUD11.Company = Session.CompanyID;</div><div><span style="white-space:pre-wrap;"> </span>NewUD11.Key1 = someValue.ToString();</div></div><div><span style="white-space:pre-wrap;"> </span>......</div><div><div><span style="white-space:pre-wrap;"> </span>// commit changes</div><div><span style="white-space:pre-wrap;"> </span>Db.Validate(NewUD11);</div><div><span style="white-space:pre-wrap;"> </span>txscope.Complete();</div><div>}</div></div><div><br>Jim Kinneman</div><div>Encompass Solutions, Inc</div><p></p> </div> <div style="color:#fff;min-height:0;"></div>
Thanks Jim. I appreciate the reply. I got this from Ken at the Epicor User Group forum and it works as well:
var ud11svc = Ice.Assemblies.ServiceRenderer.GetService<Ice.Contracts.UD11SvcContract>(Db);
Ice.Tablesets.UD11Tableset ud11ts = new Ice.Tablesets.UD11Tableset();
ud11svc.GetaNewUD11(ref ud11ts);
var newUD11Row = ud11ts.UD11.FirstOrDefault();
newUD11Row.Key1 = "Anything you want"
newUD11Row.Key2 = "Anything you want"
newUD11Row.Key3 = "Anything you want"
newUD11Row.Key4 = "Anything you want"
newUD11Row.Key5 = "Anything you want"
ud11svc.Update(ref ud11ts);
(Add a reference to Epicor.System for Ice.Assemblies.ServiceRenderer and add a reference to whatever BO you are using, in this case Ice.Contracts.BO.UD11)