Allow edit for selected fields

Hello guys,

I have a problem about allow edit propertie.

I have a budgetform and I closed the allow edit on form if the transactiontype is system,but they ask me open the allow edit on some field on form where the BudgetTransactionType::System.

I have to allow edit on qty,Note,grosssize fields on form but not all the fileds.How can I write this exception?

I wrote this code down belown for active method of datasource :

public int active()
{
int ret;

ret = super();

if(BudgetTransactionLine.BudgetTransactionType == BudgetTransactionType::System)//ı have to make a exception for qty,grosssize and note fileds in here

BudgetTransactionLine_ds.allowEdit(false);

else // BudgetTransactionType::Manuel
BudgetTransactionLine_ds.allowEdit(true);

return ret;

Then you shouldn’t be doing it on the entire data source.
Either set the allowedit of each field (or) create different group controls on the form based on the fields that needs to be enabled/disabled and set allowEdit on the group control in the form.

should I create 2 field group one allow edit true and the other is false right? BudgetTransactionLine_ds.object(fieldnum(BudgetTransactionLine,fieldgroup).allowedit(true);

Create the Groups at form level and set the auto declaration property to Yes, so that you can enable/disable them in your code.

hello kranthi thanks for your replies,i dont know how to make filed groups on form level i only know the table level.when I create how can I call the groups on code;

table.object(fieldNum(fieldgroup,table)).allowedit(); i tied this but it could not work. is this code works only for field,not filedgroup?

You need to use the Group control (Right click → New control → Group)
For this group control you can set the Data group property (select from the list of field groups on the table).

table.object(fieldNum(fieldgroup,table)).allowedit(); → this is meant for field but not field groups.

yes but I have two if;

if(BudgetTransactionLine.BudgetTransactionType == BudgetTransactionType::System)

field gruop edit true but the other fields edit false

if(BudgetTransactionLine.BudgetTransactionType == BudgetTransactionType::manuel)

all fields editable

how should I do do this.

You can use a single statement like below,
fieldGroup.allowEdit(BudgetTransactionLine.BudgetTransactionType == BudgetTransactionType::System);

thank you so much for your helps kranthi but I seriously do not know how to declare the fields group to use this code;
fieldGroup.allowEdit(BudgetTransactionLine.BudgetTransactionType == BudgetTransactionType::System);

Do you have a group controls in the form with the fields that need be enabled/disabled?
If so, set the auto declaration property of the control to Yes and use that control Name.

oh thank you kranthi i follow your words.I created two groups and I enabled the auto dec of groups but i do not know why did not worked.
if(BudgetTransactionLine.BudgetTransactionType == BudgetTransactionType::System)
{
FieldGroup.allowEdit(true);

FeldGroup2.allowEdit(false);
}

else
FieldGroup.allowEdit(true); or dataseource.alloweedit(true);

FeldGroup2.allowEdit(true);

Shouldn’t your code be like below,

if (BudgetTransactionLine.BudgetTransactionType == BudgetTransactionType::System)
{
FieldGroup.allowEdit(true);

FeldGroup2.allowEdit(false);
}
else
{
FieldGroup.allowEdit(false);

FeldGroup2.allowEdit(true);
}

yes I forgot the } in here in real code I wrote it but it did not work like this actually.

actually after else it should be like that;
FieldGroup.allowEdit(true);

FeldGroup2.allowEdit(true)

OK, mine was an example. You can change it as per your requirement.