mibuso.com

Microsoft Business Solutions online community
It is currently Sun Oct 26, 2014 6:25 am

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 38 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Stuck while coding
PostPosted: Tue Jul 03, 2012 6:01 pm 
Offline

Joined: Fri Sep 30, 2011 7:04 pm
Posts: 356
Country: Canada (ca)
My manager just sent me a mail and he wants me to implement something for him right away. But I am sorta lost. I am not sure how to begin.

Instructions:
*****Modify the No. Series table to include a new boolean field called "Used for Fixed Assets". Also, modify the Purchase Header table to include the same boolean field "Used for Fixed Assets". *****When a user selects a No. Series that has "Used for Fixed Assets" checked, then transfer the checkmark to the Purchase Header as well. If a checkmark appears in this field on the purchase header, then the purchase documents (quotes, invoices, orders) that use the No. Series that has the checkmark will be limited to selecting Fixed Asset as the line type in the line section of the document

The part in '*****' was straight forward and I completed it. I am having trouble with the part after this:

Wrote it initally in OnOpenForm(), which I later realized didnt make sense because user has to select the No. series first and once his selection is done, then i have to look if the Used for fixed asset for that no. series is checked or not. So I ended up moving it to: OnAfterGetRecord on the form (no. series), which doesnt seem to do anything (the "Used for fixed assets" does not get checked even if the no. series is checked for that field.
Code: Select all
IF "Used for Fixed Assets" = TRUE THEN
BEGIN
   PurchaseHeader."Used for Fixed Assets" = TRUE;


I am pretty sure I am missing something very stupid...


Last edited by nverma on Wed Jul 04, 2012 8:15 pm, edited 2 times in total.

Top
 Profile E-mail  
 
 Post subject: Re: Stuck while coding
PostPosted: Tue Jul 03, 2012 6:21 pm 
Offline

Joined: Thu Apr 26, 2007 2:28 pm
Posts: 325
Location: Lawrenceburg, Kentucky
Country: United States (us)
Hi,

I would not do it in the form but on the table, more specifically in the OnInsert trigger of the purchase header table.
After the call to "InitRecord" I would read the NoSeries table (308) and set your boolean there.
so it will look like this:
Code: Select all
IF NoSeries.GET("No.Series") THEN
  "Used for Fixed Assets" := NoSeries."Used for Fixed Assets";


That should do the trick,

regards,

Willy

_________________
Fostering a homeless, abused child is the hardest yet most rewarding thing I have ever done.


Top
 Profile  
 
 Post subject: Re: Stuck while coding
PostPosted: Tue Jul 03, 2012 6:40 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Fri Jun 06, 2003 9:01 pm
Posts: 7069
Location: L.I., New York
Country: United States (us)
Also note for future:
Quote:
IF "Used for Fixed Assets" = TRUE THEN

for boolean you don't have to use the = true in your condition.

IF "Used for Fixed Assets" THEN
IF NOT "Used for Fixed Assets" THEN

Quote:
PurchaseHeader."Used for Fixed Assets" = TRUE;

it's := not just =

keep reading those books [-o<

_________________
Harry Ruiz
http://www.BiloBeauty.com
http://www.autismspeaks.org


Top
 Profile E-mail WWW  
 
 Post subject: Re: Stuck while coding
PostPosted: Tue Jul 03, 2012 6:59 pm 
Offline

Joined: Fri Sep 30, 2011 7:04 pm
Posts: 356
Country: Canada (ca)
HMMMM.....I just tried what you suggested and it worked :D . I guess now it makes alot more sense now. I was trying to do this simple thing for about 2-3 hours, but it didnt come to me. :( ](*,)

Thanks savatage for the tip...i never knew that...


Top
 Profile E-mail  
 
 Post subject: Re: Stuck while coding
PostPosted: Tue Jul 03, 2012 7:10 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Fri Jun 06, 2003 9:01 pm
Posts: 7069
Location: L.I., New York
Country: United States (us)
nverma wrote:
I was trying to do this simple thing for about 2-3 hours..

After 1 you should have been asking help from your senior, and explain you need more of their time and more training.
Does your customer get charged for this time?
If it wasn't for this forum would you have spent all day on this?

_________________
Harry Ruiz
http://www.BiloBeauty.com
http://www.autismspeaks.org


Top
 Profile E-mail WWW  
 
 Post subject: Re: Stuck while coding
PostPosted: Tue Jul 03, 2012 7:36 pm 
Offline

Joined: Fri Sep 30, 2011 7:04 pm
Posts: 356
Country: Canada (ca)
I am not really sure about the inside deals of the contract between the client and our company. or how the billing works. I just do my best and tell him how many hours I spent on it.

My manager is on vacation thats why I couldn't ask him for his assistance. I am glad that you guyz are here to lend a hand. \:D/


Top
 Profile E-mail  
 
 Post subject: Re: Stuck while coding
PostPosted: Tue Jul 03, 2012 10:29 pm 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2014 attendee

Joined: Tue Aug 14, 2001 7:01 am
Posts: 5349
Location: Prague
Country: Czech Republic (cz)
Savatage wrote:
Does your customer get charged for this time?
If it wasn't for this forum would you have spent all day on this?


I don't want to imply anything about this particular case, but I definitely know of cases where a client was billed for the time that the developer spent on Mibuso. The company saw this as a reasonable thing to charge out as "research".

These days developers need to be billable with in a very short time, so proper training is not really possible.

_________________
David Singleton
Dynamics NAV Freelancer
Dynamics Book
Go-Live International


Top
 Profile E-mail WWW  
 
 Post subject: Re: Stuck while coding
PostPosted: Tue Jul 03, 2012 10:45 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Fri Jun 06, 2003 9:01 pm
Posts: 7069
Location: L.I., New York
Country: United States (us)
David Singleton wrote:
I definitely know of cases where a client was billed for the time that the developer spent on Mibuso. The company saw this as a reasonable thing to charge out as "research".

Then they should be nice enough to donate :mrgreen:
http://www.mibuso.com/donation.asp

_________________
Harry Ruiz
http://www.BiloBeauty.com
http://www.autismspeaks.org


Top
 Profile E-mail WWW  
 
 Post subject: Re: Stuck while coding
PostPosted: Tue Jul 03, 2012 11:35 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Thu Jan 02, 2003 6:37 pm
Posts: 7993
Location: Flagstaff, AZ
Country: United States (us)
David Singleton wrote:
I definitely know of cases where a client was billed for the time that the developer spent on Mibuso. The company saw this as a reasonable thing to charge out as "research".

Actually, I know of a case where the customer was charged for the time the developer waited for an answer, and the person that answered the question on mibuso was billed at double rate for the same time as an 'outside expert consultant'. So the developer might have waited around for 3 hours, answering the question may have taken a total of 10 minutes, but was charged to their customer as an outside consultant, also for 3 hours, and for twice the rate.

_________________
Daniel Rimmelzwaan
KCP Dynamics
MVP - Dynamics NAV


Top
 Profile  
 
 Post subject: Re: Stuck while coding
PostPosted: Wed Jul 04, 2012 8:15 pm 
Offline

Joined: Fri Sep 30, 2011 7:04 pm
Posts: 356
Country: Canada (ca)
Sorry to bother you guyz once again, but I have a quick question:
Once this condition is satisfied, the system should automatically set the Type (option field in purchase line) to be set to "Fixed Assets". To do this, I wrote this onInsert trigger in Purchase header.

Code: Select all
IF NoSeries.GET("No.Series") THEN
BEGIN
  "Used for Fixed Assets" := NoSeries."Used for Fixed Assets";

//*****************
PurchLine.Type := PurchLine.Type::"Fixed Asset";
PurchLine.Modify;
//*****************
END;


To me this sorta makes sense, but apparently it doesnt make sense to the system since it doesnt do anything. :-k

Why not??


Attachments:
Type.JPG
Type.JPG [ 67.81 KiB | Viewed 1242 times ]
Top
 Profile E-mail  
 
 Post subject: Re: Stuck while coding
PostPosted: Thu Jul 05, 2012 1:49 am 
Offline

Joined: Mon Oct 24, 2011 2:58 am
Posts: 142
Location: Tokyo
Country: Japan (jp)
You could try putting it on the OnNewRecord trigger on the line form.

_________________
Microsoft Certified IT Professional for Microsoft Dynamics NAV

Just a happy frood who knows where his towel is


Top
 Profile E-mail  
 
 Post subject: Re: Stuck while coding
PostPosted: Thu Jul 05, 2012 2:40 am 
Offline

Joined: Fri Sep 30, 2011 7:04 pm
Posts: 356
Country: Canada (ca)
I tried what you suggested. I had to create NoSeries record again and PurchHeader record again and I put in the same code in OnNewRecord (in purchase line subform). But nothing happened.


Top
 Profile E-mail  
 
 Post subject: Re: Stuck while coding
PostPosted: Thu Jul 05, 2012 3:51 am 
Offline

Joined: Mon Oct 24, 2011 2:58 am
Posts: 142
Location: Tokyo
Country: Japan (jp)
Could you show us the code ?

_________________
Microsoft Certified IT Professional for Microsoft Dynamics NAV

Just a happy frood who knows where his towel is


Top
 Profile E-mail  
 
 Post subject: Re: Stuck while coding
PostPosted: Thu Jul 05, 2012 7:36 am 
Offline

Joined: Wed Apr 07, 2004 9:39 am
Posts: 356
Location: Bangalore
Country: India (in)
Try the following code in the OnNewRecord trigger of the Purch Order Subform (Form no. 54):

Declare a local variable: PurchHeader - Record - Purchase Header

IF "Document No." <> '' THEN
BEGIN
IF NoSeries.GET("No.Series") THEN
BEGIN
PurchHeader.GET("Document Type","Document No.");
IF PurchHeader."Used for Fixed Assets" THEN
Type := Type::"Fixed Asset";
END;
END;


Top
 Profile E-mail WWW  
 
 Post subject: Re: Stuck while coding
PostPosted: Thu Jul 05, 2012 2:21 pm 
Offline

Joined: Thu Apr 26, 2007 2:28 pm
Posts: 325
Location: Lawrenceburg, Kentucky
Country: United States (us)
Nverma,

please see your manager and ask for some more training. I will try and help you and even try and give you the solution.
I will add notes to each step to clarify to you why I did the step.

The way to solve this issue is:
1. Create a new trigger on the Purchase Line table called for example CheckFixedAsset, this trigger should return a boolean value.
The code for this trigger should be:
Code: Select all
   GetPurchHeader;
   Exit(PurchHeader."Used for Fixed Assets" );

I created a new trigger on the table just for the purpose of central code and ease of maintenance. Forms will eventually go away, but tables will remain. If your customer wants this changed later on, you only have to change it in one place and it will work the same everywhere it is used.

2. On the all your purchase subforms (Order, Quote, Invoice, Credit Memo, Return Order) modify the existing code in the OnNewRecord trigger:
Code: Select all
   Type := xRec.Type;
   CLEAR(ShortcutDimCode);

into
Code: Select all
   IF CheckFixedAsset THEN
     Type := Type::"Fixed Asset"
   ELSE
     Type := xRec.Type;
   CLEAR(ShortcutDimCode);

I do not like to put code on Forms, but here I have to.

3. On the Onvalidate Trigger of the Type field on the Purchase Line table add the following code:
Code: Select all
  IF CheckFixedAsset THEN BEGIN
    IF ((Type <> type::" ") AND (Type <> Type::"Fixed Asset")) THEN BEGIN
     Error('Only the Line types of Fixed Asset and Comment (blank) are allowed!');
    END;
  END;

I also allowed the " " blank option to be manually entered so your customer will be able to add "Comment Lines" or blank lines.

I think this should do what is required, but please ask your manager for additional training. This will benefit you, your manager and your customers.
It does you no good when we just give you the code to problems you run in, you will not learn from this.

Let me know if you need more clarification on this.

Regards,

Willy

_________________
Fostering a homeless, abused child is the hardest yet most rewarding thing I have ever done.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 38 posts ]  Go to page 1, 2, 3  Next

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to:  
cron