CODEUNIT.RUN #2

Published 2012-10-12 11:12

Another version of my multiple choice question I posed here.

Given:

Codeunit 50000:
OnRun()
Cust.INIT;
Cust.INSERT;
Cust.INSERT; // This duplicate statement has been put here intentionally

Codeunit 50001:
OnRun()
IF CODEUNIT.RUN(50000) THEN
  MESSAGE('OK')
ELSE
  MESSAGE('LASTERRORTEXT: %1', GETLASTERRORTEXT);

Which error/message will occur when codeunit 50001 is being executed?

  1. 'OK'
  2. 'LASTERRORTEXT: The Customer already exists. Identification fields and values: No.='''
  3. 'The Customer already exists. Identification fields and values: No.='''
  4. none

Note

  • Variable Cust in codeunit 50000 is linked to the Customer table.
  • As before of course you're free to test it in NAV, but first give it a try "from the bare head".
Filed under: , ,

Comments

# Lionel said on Friday, October 12, 2012 11:54 AM

2.

# MIchael Schneider said on Friday, October 12, 2012 12:09 PM

With no testing: 2

# Natalie said on Friday, October 12, 2012 1:03 PM

No. 3

# Natalie said on Friday, October 12, 2012 1:05 PM

Sorry, in my last post was a mistyping -  I meant answer no. 2!

# Andrius said on Friday, October 12, 2012 3:26 PM

If I remember this, duplicated Inserts are not "catched" by "IF CODEUNIT.RUN", meaning that error no. 3 should pop-up.

What I did in those cases was:

1. use "if rec.insert then"

2. or use second codeunit which is trying to catch codeunit provided in the example above

# bennn said on Friday, October 12, 2012 7:37 PM

3

# Taddeo said on Monday, October 15, 2012 1:04 AM

2

# RedFox said on Wednesday, October 17, 2012 6:12 PM

2

# Luc van Vugt said on Sunday, November 18, 2012 8:51 AM

If you did run the code you could verify that answer 2 is the right one.

Now how about the next question: CODEUNIT.RUN #3

# Van Vugt's dynamiXs said on Sunday, December 09, 2012 3:13 PM

Contrary to the other run-able CSIDE objects - i.e. Page, Report and XMLport - we can run a Codeunit

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Dynamics NAV MVP

Contact

Recent Posts

Search

Email Notifications

This Blog

Tags

Favorite BLOGS

MS BLOGS

Links

Syndication

Archives