How to determine the "real" type of a customer ?

navvynavvy Member Posts: 79
Hi All,

As I understand, in a standard installation of NAV the contact of a customer must always be defined as Type "Company", that's clear.
Now I'm trying to find a way, to determine the "real" type of a customer. That means, I want figure out, if the customer is an individual person (i.e."Bill Gates") or a company (i.e. "Microsoft Corp.").

The only solution I found yet, is to go to the contact and check the "Salutation Code", but there must be a better way. That query will be done in a codeunit.

I would be very thankful if I could get as many suggestions.

Thanks and regards
navvy
Freelance Developer

Comments

  • apertierraapertierra Member Posts: 61
    Under each "company" contact you can create multiple "person" contacts.
  • navvynavvy Member Posts: 79
    apertierra wrote:
    Under each "company" contact you can create multiple "person" contacts.

    Thanks apertierra for your answer, but that makes no sense if the customer is a individual person (who doesn't work for a company).

    Example: I want to make a new order for a new customer. The customer is a person (i.e. "Bill Gates"). So I go to "Contact" and create a new "company" contact for the person. In the next step I use the function "Create as" -> "Customer" (this function is only available, if the contact is defined as Type "Company")

    I think, if a CAL function wants to determine the "real type" of a customer, it must check the "Salutation Code" of his contact.....
    navvy
    Freelance Developer
  • nunomaianunomaia Member Posts: 1,153
    navvy wrote:
    apertierra wrote:
    Under each "company" contact you can create multiple "person" contacts.

    Thanks apertierra for your answer, but that makes no sense if the customer is a individual person (who doesn't work for a company).

    Example: I want to make a new order for a new customer. The customer is a person (i.e. "Bill Gates"). So I go to "Contact" and create a new "company" contact for the person. In the next step I use the function "Create as" -> "Customer" (this function is only available, if the contact is defined as Type "Company")

    I think, if a CAL function wants to determine the "real type" of a customer, it must check the "Salutation Code" of his contact.....

    You could add a new field to overcome this.
    Nuno Maia

    Freelance Dynamics AX
    Blog : http://axnmaia.wordpress.com/
  • navvynavvy Member Posts: 79
    nunomaia wrote:
    You could add a new field to overcome this.

    I can't add a new field to NAV, because the CAL Function (Codeunit) will be installed on different (long-existing) NAV-installations ](*,)
    navvy
    Freelance Developer
  • DaveTDaveT Member Posts: 1,039
    Hi Navvy,

    Without adding a field then you are restricted to using a standard field
    The two that come to mind is the Industry Group code from the Company type contacts or Type of supply on the customer card.

    If these are not an option then have you considered using a dimension for this ?
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • navvynavvy Member Posts: 79
    DaveT, thanks for your answers.
    DaveT wrote:
    Hi Navvy,
    Without adding a field then you are restricted to using a standard field

    > yes, I want to make a "simple" query, I cannot make any changes to the existing NAV-Installations.
    DaveT wrote:
    The two that come to mind is the Industry Group code from the Company type contacts or Type of supply on the customer card.

    >"Industry Group code": Good idee, but, I don't think that many NAV-customers use this field (correctly)

    > "type contacts": Do you mean the field "Copy Sell-to Addr. to Qte From" on the tab "Invoicing" ? That can be the solution! :D I have to check this out...

    > "Type of supply": Unfortunately I can't find this field on the customer card.... :(
    DaveT wrote:
    If these are not an option then have you considered using a dimension for this ?

    > that's not an option, see above.
    navvy
    Freelance Developer
  • DaveTDaveT Member Posts: 1,039
    Hi Navvy,
    navvy wrote:
    "type contacts": Do you mean the field "Copy Sell-to Addr. to Qte From" on the tab "Invoicing" ? That can be the solution! :D I have to check this out...

    I just meant that industry group is only for "Customer" (type) contacts

    The type of supply should be on the invoicing tab on the customer card (V5 & V4) and I'm not sure what it's used for but may suit you to use it.

    Hope this helps
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • nunomaianunomaia Member Posts: 1,153
    Using other fields to identity customer type can be tricky. For example if customer change settings it could lead to an error. I don’t exactly what you mean by an old version and you can’t add fields.
    Nuno Maia

    Freelance Dynamics AX
    Blog : http://axnmaia.wordpress.com/
  • navvynavvy Member Posts: 79
    nunomaia wrote:
    Using other fields to identity customer type can be tricky. For example if customer change settings it could lead to an error. I don’t exactly what you mean by an old version and you can’t add fields.

    ok, it's hard to explain this but I will do my best... :wink:

    I am building a connector (NAV Add-on) for the open-source shop-system osCommerce. This shop makes a clear difference between person- and company-customers (i.e. different table-fields on DB)

    It should now be possible, that a user can "mark" a customer in NAV for "open this customer in the Shop". The connector will then export this customers to the shop (and send them a password for login). For this process, the connector (only a special codeunit) have to determine the "real" type of a customer.

    Important is, that the integration of this Add-on is without impact on an existing NAV-installation (i.e. it should not be necessary to make any changes on existing customer data when installing the connector).

    I think I have to use different standard fields to identify the customer type #-o
    DaveT wrote:
    The type of supply should be on the invoicing tab

    I must be blind, I can't see this field: screenshot
    navvy
    Freelance Developer
  • nunomaianunomaia Member Posts: 1,153
    Well, I have build a few NAV connectors (Web Services, SQL, etc) and most of them add some kind of field or code change. It’s impossible to avoid such restrictions.
    I have seem add-on larger than Navision and it makes changes every in many places.

    If you don’t want to change customer table. You could add a new table that related customer No. and your classifications. In that way users can change every parameter without affecting your connector.
    Nuno Maia

    Freelance Dynamics AX
    Blog : http://axnmaia.wordpress.com/
  • navvynavvy Member Posts: 79
    nunomaia wrote:
    Well, I have build a few NAV connectors (Web Services, SQL, etc) and most of them add some kind of field or code change. It’s impossible to avoid such restrictions.
    I have seem add-on larger than Navision and it makes changes every in many places.

    It's hard but I think it's not impossible in my case. The connector is written in C# . At the moment, my connector can do many things (i.e. import new orders, export articles, import new contacts / customers) without the need of make any changes to a NAV installation (and only a new codeunit must be licensed)
    nunomaia wrote:
    If you don’t want to change customer table. You could add a new table that related customer No. and your classifications. In that way users can change every parameter without affecting your connector.

    At the moment, that's not an option....
    navvy
    Freelance Developer
  • DaveTDaveT Member Posts: 1,039
    Hi Navvy,

    The field "Type of supply" must be a localised field -> it's field 10500 on the customer table on IE/GB version (Also W1 I think)

    Another suggestion is to modify codeunit 5056 CustCont-Update and have different business relation codes for the different contact type.
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • navvynavvy Member Posts: 79
    DaveT wrote:
    Hi Navvy,

    The field "Type of supply" must be a localised field -> it's field 10500 on the customer table on IE/GB version (Also W1 I think)

    Another suggestion is to modify codeunit 5056 CustCont-Update and have different business relation codes for the different contact type.

    Hi DaveT,

    Thanks for this information. Change the codeunit 5056 CustCont would be an option, but it should not be required to make any changes of a NAV installation.

    Question: Is it possible in CAL, to test if a field exist in a table ? i.e. I want to use the field "Type of supply" if it exists...
    navvy
    Freelance Developer
  • DaveTDaveT Member Posts: 1,039
    Hi Navvy,

    There is the system table 2000000041 Field which has all the table fields in it. I have seen a post (and tried it out) where you can add a record in this table and it adds the field to the corresponding table. It worked for me but I'm not sure how robust it is for commerical use (worth a try :wink: ) - also you cannot set any properties except type, length and table relation.

    Hope this helps
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • navvynavvy Member Posts: 79
    This table would be great, but in my NAV (German / SQL) there is no table "2000000041".... :(

    Last question: :wink:
    I've defined the new field "Nickname" in table "customer". When I use this field in a codeunit (in the NAV where this field is defined) it's working, but if I run the codeunit on another NAV (where the field "Nickname" doesn't exist) the following error occured:
    Reference to the member Nickname of the variable could not be solved.
    

    In PHP I use the function isset() and in C# I use try/catch to see if a variable exists. Is there a way in CAL, to check if a variable (like Nickname) exists and use them?

    All suggestions are welcome.
    navvy
    Freelance Developer
  • DenSterDenSter Member Posts: 8,305
    The German version does have that table, you just don't know where to find it. It is what is called a "Virtual Table", and you can find it in the variable list for Record type variables, and it is also available to select as source table for forms.

    When something is a field in a table, it is not called a variable. When accessing the table directly there is no way to see if there is a field called 'whatever', but you can use the field table, and you can also probably use RecRef functionality, although I'm not sure if that will work.
  • navvynavvy Member Posts: 79
    Thanks a lot DenSter for the info. "Virtual Table"... ok, I think I have to read the manual (Chapter 8 - Special C/SIDE Tables :wink:)
    When something is a field in a table, it is not called a variable.....
    Sorry, I've mixed CAL with C#/LINQ..... ](*,)

    Very last question: Is there a way to insert data in fields "defined" dynamically by text-variables ?

    Example:

    fieldName := 'Nickname'; //the name of the table-field
    fieldValue := 'Mike'; //the value of the table-field

    customer.fieldName := fieldValue; //should insert 'Mike' to the field 'Nickname' in table customer
    navvy
    Freelance Developer
  • DaveTDaveT Member Posts: 1,039
    Hi Navvy,

    I have not done this in practice but the Recref as Danial suggested should work. Look at the codeunit 8611 Migration Management to see how it's handle as standard
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • navvynavvy Member Posts: 79
    Hi DaveT,

    Thanks for your help. I will now write a test. After that I come back here....

    navvy
    navvy
    Freelance Developer
Sign In or Register to comment.