How Do the specialised classes like DataPage and DataPageEdit know which record to use?

1 minute read time.

Imagine you need to create a new entity. I have made the assumption you have created a new Visual Studio project using the Entity wizard in the SDK.

You can click the new button, this will call the default method RunDataPageNew. You will then enter the data and then you end up at the RunDataPage method.

How does the RunDataPage which contains the DataPage specialised class know which record to use?

Lets start with the point at which the record is created.

Consider the code in DataPageNew class


public class projectDataPageNew : DataPageNew
{
public projectDataPageNew()
: base("project", "proj_projectid", "projectentryscreen")
{
}

public override void BuildContents()
{
base.BuildContents();
}
}

The class assumes that when the entry form is submitted it the project record will be saved and the screen redirected to the new method (by default RunDataPage).

The exact method you redirect to can be changed be changing the AfterSave property. In my code above it knows it is saving an project and it knows which field is the unique identifier.

If you look at the training material you'll see that the record created is available so the new created ID is known to the class. You can find the latest slides here:

This allows the URL to be built that redirects to the RunDataPage method

http://localhost/crmdpp/eware.dll/Do?SID=159615455777779 &Act=432 &Mode=1 &CLk=T &Key0=1 &Key1=28 &Key2=30 &Key7=217 &proj_projectid=217 &func=datapageurl &dotnetdll=DummyEntity &dotnetfunc=RunDataPage

The specialised DataPage class used in the RunDataPage method will use the unique identifier passed in the URL to retrieve the newly created record.

That is all assumed in the code below


public class projectDataPage : DataPage
{
public projectDataPage()
: base("project", "proj_projectid", "projectentryscreen")
{
}
public override void BuildContents()
{
base.BuildContents();
}
}

So the most import thing to realise is that the class gets the knowledge of which record to use from the URL that is passed to it.

This means that you could for example redirect to an other method using the the AfterSave of the DataPageNew specialised class, which may carry out another taks and when you need to return to the DataPage or DataPageEdit then you would only need to build the correct URL.

This can be done using the UrlDotNet() method

e.g.


UrlDotNet(ThisDotNetDll, "FunctionName")+" &proj_projectid="+intRecordID);

Parents Comment Children
No Data