locked
Default value for phone number ? RRS feed

  • Question

  • hi, im making a delivery schedule and progress tracking lightswitch application with visual studio 2012 and would like to set a default value for a phone number but the following wont work:

            Private Sub CSRDirectDial_Created()
                Me.CSRDirectDial = "0197766"
            End Sub

    the idea is that this would show the direct dial numbers for the customer sales representatives so i would like the field to show "0197766" as this would be the same for all the customer sales representatives which would have their 4 number unique direct number after that so for example "01977665053"

    i'm not sure whether this is possible with the phone number data type or not? or if it would be better to use the text data type as i would in microsoft access?

    may be this is obvious to some of you but i am new to lightswitch as i usually develop for Microsoft access

    thanks in advance,

    Luke

    Tuesday, September 24, 2013 10:49 AM

Answers

  • For desktop, you can do the following:

    • Click on the Wirte Code drop down and select EntityName_Created (in my example my entityName is employee)

    • Write the following code:
    private Sub Employee_Created()
        Me.Phone = "0197766"
    End Sub

    for the data type question, Using a phone number helps in validating the format of the input value. If you don't care about that, you can use Integer or string.


    • Edited by Amr Altahlawi Tuesday, September 24, 2013 3:22 PM
    • Proposed as answer by NESTicle 8Bit Tuesday, September 24, 2013 6:45 PM
    • Marked as answer by Luke Varley Monday, September 30, 2013 10:55 AM
    Tuesday, September 24, 2013 3:22 PM

All replies

  • Hi Luke,

    Could you let me know what is the client type you are using. I'm asking this because the way to solve this varies between Silverlight client and HTML client.

    For Silverlight client, you can create  a method "EntityName_Created" and add your code there. For HTML client, you can go to the screen and create the Created method, then write something like the following:

    myapp.AddEditEmployee.created = function (screen) {
        // Write code here.
        screen.Employee.Phone = "0197766";
    };

    Tuesday, September 24, 2013 1:48 PM
  • Hi Amr

    i am developing for desktop but am using VB

    thanks,

    Luke

    Tuesday, September 24, 2013 2:53 PM
  • For desktop, you can do the following:

    • Click on the Wirte Code drop down and select EntityName_Created (in my example my entityName is employee)

    • Write the following code:
    private Sub Employee_Created()
        Me.Phone = "0197766"
    End Sub

    for the data type question, Using a phone number helps in validating the format of the input value. If you don't care about that, you can use Integer or string.


    • Edited by Amr Altahlawi Tuesday, September 24, 2013 3:22 PM
    • Proposed as answer by NESTicle 8Bit Tuesday, September 24, 2013 6:45 PM
    • Marked as answer by Luke Varley Monday, September 30, 2013 10:55 AM
    Tuesday, September 24, 2013 3:22 PM