A functionality was added to the Job card, which allows the user to copy a job card, so they dont have to enter the information over and over again.
But, recently a user report, that the copy job function is not working, it throws an error: "The Job task already exists....Identification Fields and Values.. Job No = HV18701 Job Task No = 01.
I went to look for this Job Task No, it doesnt exists in the system (I made sure that no filters were on).
However, I noticed something very strange, it allows me to copy certain Jobs but not all of em. Any ideas what might be the issue.
Code to copy.
// Copy the job details from the source job to the new job
lrecNewJob.INIT;
lrecNewJob."Program" := CurrentJob."Program";
lrecNewJob.INSERT(TRUE);
lrecNewJob.TRANSFERFIELDS(CurrentJob,FALSE);
lrecNewJob.Status := lrecNewJob.Status::"Pre-Service";
lrecNewJob."Renewal Job No." := '';
lrecNewJob."Contract Renewal Date" := 0D;
// Set the Original Job No. to the passed job's number.
lrecNewJob."Original Job No." := CurrentJob."No.";
lrecNewJob.MODIFY;
// Copy the associated job tasks from the source job to the new job
JobTask.SETRANGE("Job No.", CurrentJob."No.");
IF JobTask.FIND('-') = TRUE THEN
REPEAT
NewJobTask.INIT;
NewJobTask.TRANSFERFIELDS(JobTask);
NewJobTask."Job No." := lrecNewJob."No.";
NewJobTask.INSERT;
UNTIL JobTask.NEXT = 0;
// Return the new job's number
EXIT(lrecNewJob."No.");
After doing a bit more snooping around, I found out that, if I am successfully at copying the job (a new job card is created with the same information...When I try to copy this new card, it throws the error message). Any idea how I can fix this.
Comments
Turn on the debugger, step through the code, keep track of values, compare those values against what you are expecting, figure out what is going wrong and fix it. Start again, until you solve the issue.
Hint: it is trying to insert the same record more than once, so you need to figure out where that is going wrong. Use the values in the error message as clues and investigate.
Good luck
RIS Plus, LLC
I wil keep trying to debug it
I know exactly what the problem is just from looking at your code, you need to learn to figure it out. I really hope nobody steps in and tells you because I think this is a very important lesson for you to learn.
RIS Plus, LLC
The (18701) no was assigned using a no. series.
The issue is with the field: JOb Tasks No.
Since we have copied it once, the Job Tasks No is 01, so when we try to copy it again the next time, the job task no. still stay at 01, rather then get incremented???
Thanks Den, for pointing me in the right direction. :thumbsup:
What happens if the original job has more than one task, or if the original job has a task that has a value for the task number? You have to be able to loop through a set of data, copy that data and insert all of them with new key values.
See this is the problem with you not having a senior. You don't have someone sitting next to you explaining how stuff works. You've been at this for months and still you are not making any meaningful progress, you are making the same mistakes over and over and it doesn't look like you understand basic concepts. Go to your boss and ask for senior support.
RIS Plus, LLC
Thats why i made it only add a task no. if its empty.
RIS Plus, LLC
I know I aint no professional and I am still in the learning phase, but its not very nice to put someone down, just because they aint as skilled as you. I bet when you started off, you weren't as good aswell, but with time you learned things. But if every time you got stuck (when you were new), and someone rubbed it in ur face, that you are not good (you haven't learned anything) that's just a douche bag move (but what do i know, I am just a newbie)
I aint here to start a fight or anything, just like you I am trying to make a living, so cut me some slack just caz i aint as knowledgeable as you.
I'm not putting you down, but I'm not going to apologize for being direct with you. You were dismissing the idea that it is still not good, and I was calling you on it. I'm also identifying the fact that you seem to have no help from a senior, and no prper training, which is the biggest problem here. If you DID have a senior, if you DID get the proper training, you would be ten times the developer that you are now. The only thing you have is help from this forum, you're asking the wrong questions, you're getting really bad advice from some people, and as a result you are developing some REALLY bad habits.
This should be addressed by your boss. Your employer should provide everything you need to succeed, and you're obviously not getting it. That's not your fault but it IS a problem.
I've spent significant time trying to provide some guidance to you, and see if I could give you some sort of 'online senior' guidance. At first I thought I saw that you were really making some good progress, but I can clearly see the frustration building, so that proves yet again to me that this forum is NOT the right place for that type of help. It looks like you really just want people to tell you what the code should be instead. That's fine with me, but I'm not here to write your code for you.
RIS Plus, LLC
I think I got the problem now. I just have to write a condition in my code to create a job task if no job task exists ( i think that might fix the issue).
Create a new job manually (make sure that you give it a description, assign a bill-to, enter an address, etcetera), and make sure that it has 2 or 3 tasks associated with it. You can also go through the list of existing jobs and select one that has multiple tasks. Then run the routine that you programmed for it. Verify that the new job has all the fields copied, and all of the tasks are also copied into the new job. When you have verified that the job (with all the field values) and tasks copy properly, then come back and tell us that it is solved.
RIS Plus, LLC
I gotta find a way around this.
This simple little issue is starting to turn into such a big headache. ](*,) ](*,)
@ Den - I wish I get to be as good as you one day. You just looked at the code and you told me the reason the code wont work. You got some major SKILLZZZ!! =D>
RIS Plus, LLC
Thast all i remember.
"If the Program Setup contains default Job Task No. then don't even add the job tasks from the job to be copied.
If the new job doesn't have a job task defined, only then do you copy the job task from the job to be copied
If the new job contains job tasks (done through Program Setup), then you skip copying job tasks"
Now I sorta, know where I am going.
This is sorta off topic, how do you delete a message in a post??? Is that even possible?
The reason why I am asking about primary key is because if you really understand that, you will also understand how filters on a compound primary key will affect what you need to take care of for a new job. The job task are related to the job by way of the job number, so when you copy a job task from one job to another, all you need to do in the new job task is use the new job number.
Filter on the old job number, loop, copy the record and change the job number, insert.
RIS Plus, LLC
For Instance, when a user creates a job card, it will automatically fill it with a default information for job task (Thats why when a job a created it will have a default job task no., Cost Center Code, etc)
From the requirements my manager told me to do: I wrote this code and I thought it should have worked, but its not working. I have tried debugging it 5-6 times, but debugger keeps on crashing.
Any idea what might be causing the debugger to crash. I am pretty sure there is a flaw in my logic somewhere.
RIS Plus, LLC
Just one last question (I refuse to give you on this):
According to my manager this is what needs to be done. I have read these lines like atleast 50 times, I just want to run by you what I understood and you can tell me if I am on the right path.
1) "If the Program Setup contains default Job Task No. then don't even add the job tasks from the job to be copied. --> If ProgramSetup has a default Job Task No. assigned to it, then we should not copy any Job tasks
2) If the new job doesn't have a job task defined, only then do you copy the job task from the job to be copied --> This will never be the case, since when we create a job, it will always has a default job tasks, so I dont have to copy anything since it will never be empty (doesnt have job task). I am not really sure about this point.
3) If the new job contains job tasks (done through Program Setup), then you skip copying job tasks" --> This is basically the same thing as 1
RIS Plus, LLC