|
This topic explains how to use extra fields in the SDK.
Extra fields are defined in the templates for the project module and are added dynamically to the
file during runtime. Therefore, they cannot be consulted or written using the properties of an
interface.
Instead they must be approached by the GetFieldVal and
the SetFieldVal method, provided with the field identifier
as a parameter. You can retrieve this field identifier with the method GetFieldID
based on the code of the extra field, combined with the template code.
|
|
Remarks |
|
Setting the extra fields can only be done when the project is completely
handled programmatorically using the PrepareProject
and WriteProject methods. If you do not use
this method, using the SetFieldVal method for
extra fields will throw an exception.
|
|
Extra fields are belong to a specific template and can only be set for a
project if the template code for the project is already known. If the value of an extra
field is set before the template code was set, an exception will be thrown.
|
|
|
The samples below use the Project interface and
are based on the assumption that a template with code 'DOCU' is defined, containing a numerical extra field
with code 'NumUsers'.
|
|
See Also |
|
|
Samples |
|
|
C++ |
|
// Getting the value of an extra field
double lfNumUsers = pProject->GetFieldVal (pProject->GetFieldID ("DOCU_NumUsers")).dblVal;
// Setting the value of an extra field, using the PrepareProject/WriteProject routine
pProject->PrepareProject (paUpdate);
pProject->SetFieldVal (pProject->GetFieldID ("DOCU_NumUsers"), 3.0);
pProject->WriteProject (rmFullReport);
|
|
|
C# |
|
// Getting the value of an extra field
double lfNumUsers = (double)oProject.GetFieldVal(oProject.GetFieldID("DOCU_NumUsers"));
// Setting the value of an extra field, using the PrepareProject/WriteProject routine
oProject.PrepareProject (ePrepareAction.paUpdate);
oProject.SetFieldVal (oProject.GetFieldID ("DOCU_NumUsers"), 3.0);
oProject.WriteProject (eReportMode.rmFullReport);
|
|
|
VBS |
|
' Getting the value of an extra field
Dim lfNumUsers
lfNumUsers = oProject.GetFieldVal(oProject.GetFieldID("DOCU_NumUsers"))
' Setting the value of an extra field, using the PrepareProject/WriteProject routine
oProject.PrepareProject(paUpdate);
oProject.SetFieldVal(oProject.GetFieldID ("DOCU_NumUsers"), 3.0);
oProject.WriteProject(rmFullReport);
|
|
|
VB.NET |
|
' Getting the value of an extra field
Dim lfNumUsers As double
lfNumUsers = oProject.GetFieldVal(oAccnt.GetFieldID("DOCU_NumUsers"))
' Setting the value of an extra field, using the PrepareProject/WriteProject routine
oProject.PrepareProject(ePrepareAction.paUpdate);
oProject.SetFieldVal(oProject.GetFieldID ("DOCU_NumUsers"), 3.0);
oProject.WriteProject(eReportMode.rmFullReport);
|
|
|