Hi
How to add a default Check Box default value as 1 when creating a new employee.
In the Form DataSource tableI have added the below
public void initValue()
{
super();
CAEEmplTable.LeaveFinancials =NoYes::Yes;
}
With the above code default value is not been added . If am not clear with the above ,please let me know.
Thanks
Do you mean creating a worker (HCMWorker)? CAEEmplTable is that a custom table?
If so, how the record is being inserted into this table?
Thanks for the response… It is a custom table for a customized form CAEHcmWorker. HCMWorker table is linked with CAEEmplTable and written a code in the insert method of HCMworker as shown below
public void insert()
{
DirRelationshipTypeTable dirRelationshipTypeTable;
CAEEmplTable caeEmplTable;
CaePR caepr ;
#DirParty
boolean replicate = false;
if (isConfigurationkeyEnabled(configurationKeyNum(Retail)))
{
replicate = RetailConnActionManagement::shouldReplicate(this, this.orig(), false);
}
dirRelationshipTypeTable = DirRelationshipTypeTable::findBySystemType(DirSystemRelationshipType::Worker);
ttsbegin;
super();
// Create relationship in DirPartyRelationship between the worker party and the System LE
// This is used for the GAB XDS policies for performance reason so that the party record will be returned in the same query as
// parties stripped by DataAreaId
DirPartyRelationship::createRecordRelations(dirRelationshipTypeTable.RelationshipTypeId, 0,this.Person,#SystemDataAreaId);
// We need to remove the PartyInLE relationship if one exists
DirPartyRelationship::removeLegalEntityRelationship(this.Person, DirSystemRelationshipType::PartyInLE);
if (replicate)
{
RetailConnActionManagement::createActions(this, RetailConnActionUpdate::Insert);
}
ttsBegin;
caeEmplTable = caeEmplTable::find(this.RecId,true);
caepr = caepr::find(this.RecId,true);
if(caeEmplTable.RecId)
{
caeEmplTable.EID = this.PersonnelNumber;
caeEmplTable.Person = this.Person;
caeEmplTable.Name = this.name();
//caeEmplTable.TitleName = this.title();
//caeEmplTable.TitleClassEnum = HcmTitle::findByTitle(caeEmplTable.TitleName).TitleClass;
caeEmplTable.update();
}
else
{
caeEmplTable.EID = this.PersonnelNumber;
caeEmplTable.Worker = this.RecId;
caeEmplTable.Person = this.Person;
caeEmplTable.Name = this.name();
// caeEmplTable.TitleName = this.title();
//caeEmplTable.TitleClassEnum = HcmTitle::findByTitle(caeEmplTable.TitleName).TitleClass;
caeEmplTable.insert();
}
/* if(caepr.RecId)
{
caepr.EmplId = this.PersonnelNumber;
caepr.update ();
}
else
{
caepr.EmplId = this.PersonnelNumber;
caepr.insert ();
}*/
ttsCommit;
ttscommit;
flushCurrentWorker();
}
Thanks
You are creating a record in your table while inserting a record in HCMWorker table, so i don’t see a need to have a default value for one field as you are not using any of that buffer values (form data source) during the insert?
Hi,
I have written the code in the HCMworker insert method . Now its working. Hope the solution will not affect any other customization
Thanks
I need to use the checkbox value somewhere else outside AX. That’s the reason I need to have a checkbox with default 1 . And user can change the checkbox value to 0 as required. it would be rare case to have checkbox with 0
You mean inserting the data into this from external applications? Have you written your code in initValue of table (table level) or on form data source (form level)?