Modify massive values

MarkReeda
Member Posts: 12
Goodmorning everyone,
I'll explain my problem. I'm trying to create a button to insert into a generic Page (suppose for example that of the articles) that I will need to do "massive" operations on them; for example, I would like to select some articles by pre-filtering them, (eg select all articles starting with * 1234) and apply changes on one (or more) fields of them (eg change the description field to all articles starting with * 1234).
I have reached the point where I can select the desired table and the field to modify, but when I try to make changes to the value of the field in question, I receive errors but I do not understand why ["The Item does not exist. Identification fields and value: No. = ']. I adhered to the guides of the Community, even sifting through the web I always found the same procedure to perform, very very similar to the following (the following code is the one that I really implemented!)
Fields.RESET;
Fields.SETRANGE (TableNo, 27);
Fields.SETRANGE (Enabled, TRUE);
IF PAGE.RUNMODAL (PAGE :: "Field List", Fields) = ACTION :: LookupOK THEN BEGIN
SelectedField: = Fields.FieldName;
FieldNumber: = Fields. "No.";
RecRef.OPEN (27);
FldRef: = RecRef.FIELD (FieldNumber);
IF FldRef.ACTIVE THEN
BEGIN
FldRef.VALUE: = 12345678;
RecRef.MODIFY;
END;
END;
SelectedField and FieldNumber are text fields, while RecRef and FldRef are respectively of RecordRef and FieldRef.
Could someone please explain to me politely what error I am committing? Many thanks in advance
I'll explain my problem. I'm trying to create a button to insert into a generic Page (suppose for example that of the articles) that I will need to do "massive" operations on them; for example, I would like to select some articles by pre-filtering them, (eg select all articles starting with * 1234) and apply changes on one (or more) fields of them (eg change the description field to all articles starting with * 1234).
I have reached the point where I can select the desired table and the field to modify, but when I try to make changes to the value of the field in question, I receive errors but I do not understand why ["The Item does not exist. Identification fields and value: No. = ']. I adhered to the guides of the Community, even sifting through the web I always found the same procedure to perform, very very similar to the following (the following code is the one that I really implemented!)
Fields.RESET;
Fields.SETRANGE (TableNo, 27);
Fields.SETRANGE (Enabled, TRUE);
IF PAGE.RUNMODAL (PAGE :: "Field List", Fields) = ACTION :: LookupOK THEN BEGIN
SelectedField: = Fields.FieldName;
FieldNumber: = Fields. "No.";
RecRef.OPEN (27);
FldRef: = RecRef.FIELD (FieldNumber);
IF FldRef.ACTIVE THEN
BEGIN
FldRef.VALUE: = 12345678;
RecRef.MODIFY;
END;
END;
SelectedField and FieldNumber are text fields, while RecRef and FldRef are respectively of RecordRef and FieldRef.
Could someone please explain to me politely what error I am committing? Many thanks in advance
0
Best Answer
-
So your entire code was in that OnAfterGetRecord trigger? I doubt that, otherwise the user would have to select a field for every record in the filter range.
I'm not using a filter command because that's what the DataItem is for. The item record in the OnAfterGetRecord trigger is already filtered, we just "copy" it to the RecRef variable.5
Answers
-
The purpose of your code is to let the user select a field of table 27 and then modify this field on every record? I'm not going to ask why this should be possible, but you're missing to retrieve the record(s) you want to modify. Something like
BEGIN // set some filters here if RrecRef.findset(true,true) then REPEAT FldRef.VALUE: = 12345678; RecRef.MODIFY; UNTIL RecRef.NEXT = 0; END;
You know you can modify all records within a filter range with MODIFYALL if you drop recordreferences? Just asking, because you set a fixed filter for table 27 on the fields table.0 -
Well, it's probably what I need; another thing that is bearing in my mind is that since I'm using a report to make this operation, I thought that by filtering the fields on the page, the code was executed on the already filtered fields! Apparently you're telling me it's not like that, so how can I "pass the filters" selected in the "Item's page"?0
-
You need to be more clear about what you want to achieve before we can talk about where the error in your code is.
Is the user supposed to just select a field of one specific table to modify? Where does the new value of that field come from? Where do the filters for that table come from?0 -
."is the user supposed to just select a field..." : yes
."Where does the new value of that field come from" : until now I can set this value "statically" in my code, later I will think about how to handle dynamically.
."Where do the filters for that table come from" : the filters come from the request page of the report
Let's say that as first step I will be happy to be able to modify the value of a field of some records "manually", I will explain better: I can insert the values manually in my code, so this means that I will pass the "field number" manually, the table number manually, the FieldRef VALUE manually etc etc. The only thing that I want to achieve as first step is to "get/obtain" the value filtered in the request page, inside my code0 -
So the report has a single DataItem for the item table, and this is where the user sets filters? Try this in the DataItem:
Item - OnPreDataItem() RecRef.OPEN(27); Item - OnAfterGetRecord() RecRef.GETTABLE(item); FldRef := RecRef.FIELD(SelectedField) FldRef.VALUE(NewValue); RecRef.MODIFY; Item - OnPostDataItem() RecRef.CLOSE;
0 -
Well but this is exaclty what I did. You told me to use the Filter function, why you're not using it now?0
-
So your entire code was in that OnAfterGetRecord trigger? I doubt that, otherwise the user would have to select a field for every record in the filter range.
I'm not using a filter command because that's what the DataItem is for. The item record in the OnAfterGetRecord trigger is already filtered, we just "copy" it to the RecRef variable.5 -
Ok, the first step work Sir!0
-
[Topic moved from 'NAV/Navision Classic Client' forum to 'NAV Three Tier' forum]
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions