Some Help
let opt := dialog("Transfer data", "Select what you want to transfer", ["Cancel", "Major Project", "Small Project"]);
let count := 0;
if opt != "Cancel" then
for a in select 'Activities List' do
if opt = "Major Project" and a.Type_Project = 1 or
opt = "Small Project" and a.Type_Project = 2 then
let e := (create 'Estimate Budget');
" Asignación de campos ";
e.(IDCod := a.IDCod);
e.(Activities := a.Activities);
e.('Group Work' := a.'Group Work');
e.(Discipline := a.Discipline);
" Horas según tipo de proyecto ";
if a.Type_Project = "Major Project" then
e.(Hours := a.'Major Hrs')
end;
if a.Type_Project = "Minor Project" then
e.(Hours := a.'Minor Hrs')
end;
count := count + 1
end
end;
alert("Transfer completed.\ Records copied: " + text(count))
end
The Type_Project is a Multiple choice dyn with 2 option (Major Project and Small Project)
Something is wrong.
Only copie the Small Project
The problem is the same with Mulriple Choice or Muktiole Choice dyn
7 replies
-
Multi- choice (simple or dynamic) can return an array of selections. The best way to deal with it is to use the contains() command.
if (opt = "Major Project" and contains(a.Type_Project, 1)) or (opt = "Small Project" and contains(a.Type_Project, 2)) thenAlso you might want to try to put parenthesis around the grouping.
-
Hi
I hope you don't mind me looking at your code. I see it as a challenge to make it as succinct as possible and I have come up with
let options := ["Cancel", "Major Projects", "Small Projects"]; let opt := index(options, dialog("Transfer data", "Select what you want to transfer", options)); if opt then let b := select 'Activities List' where number(Type_Project) = opt or number(Type_Project) = 3; for a in b do (create 'Estimate Budget').( IDCod := a.IDCod; Activities := a.Activities; 'Group Work' := a.'Group Work'; Discipline := a.Discipline; 'Hours Est' := if opt = 1 then a.'Major Hrs' else a.'Minor Hrs') end; alert("Transfer completed. Records copied: " + count(b)) endSo what's going on here?
Lines 1 & 2 By defining the options in an array and using the index() function the variable opt now equals 0, 1, or 2
Line 3, by design if 0 is false, and if 1 or if 2 is true
Line4 opt can now be used in the select
Line 11 Use the if in the value assigned
Regards John
Content aside
- Status Answered
- yesterdayLast active
- 7Replies
- 43Views
-
3
Following
