
Question:Within SalesLogix v7.5.2 I have created a new entity called Project.
The Project entity has an Opportunity as its parent, which is a
one-to-many off of Opportunity. In the Opportunity Projects tab I have
an Add button on the Opportunity Detail which displays a form and lets
you create a new Opportunity Project record.
I created an OnLoad code snippet event:
public static partial class AddEditProjectEventHandlers
{
public static void OnLoad1Step( IAddEditProject form, EventArgs args)
{
IProject Project = form.CurrentEntity as IProject;
if (form.txtDescription.Text == “”)
{
Project.Description = “Test”;
}
{
}
This
is so that I can default, upon creation, to the description of the
Opportunity (I have a Description
field on the Project). The Project description sets to “Test” if it is
currently blank. I have tried to use many combinations of object
hierarchies and GetParentEntity() as I can think, but I can’t seem to
get the reference to the parent Opportunity, and that Opportunity’s
Description. Where am I going wrong?
Answer: The function is part of the SmartPart, and is defined in the
EntityBoundSmartPart class, which all QuickForms inherit from. To
access the parent entity in a C# Snippet action do this:
Sage.Entity.Interfaces.
You don’t have to directly access the SmartPart if you’re in a Code
Snippet Action, so you can use the EntityContextService like this:
// Get a reference to the EntityContextServce
// and call GetEntity()
IMyParentEntity myparent = form.WorkItem.Services.Get<
Subscribe To Our Newsletter
Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!
You have Successfully Subscribed!