4 Replies - 632 Views - Last Post: 29 August 2013 - 06:28 AM

#1 belgarion262  Icon User is offline

  • Prince of all (2) Saiyans

Reputation: 146
  • View blog
  • Posts: 891
  • Joined: 25-October 09

Expecting more source characters

Posted 29 August 2013 - 01:58 AM

I'm programming some form automation in Microsoft CRM, using visual studio as my main tool. When in visual studio, i get the warning "Expecting more source characters". And when I run the code in CRM (onload and onSave) , i get an error

Posted Image


This is the code I'm running.


function formatPostcode() {
    var postCode = Xrm.Page.getAttribute("gcs_postcode").getValue();
    var postcodeRegEx = /([A-Z]{1,2}[0-9]{1,2})[\s]{1}[0-9][a-zA-Z]{2}/;
    if (postcodeRegEx.match(postCode)) {
        alert("Postcode apparently Correct");
         }
    else {
    postcodeRegEx = /([A-Z]{1,2}[0-9]{1,2})[0-9][a-zA-Z]{2}/;
    if (postcodeRegEx.match(postCode)){
    var half1;
    var half2;
        if (postCode.String.indexOf(" ") === 4 || postCode.String.indexOf(" ") === 3) {

        }
        else {
            if (postCode.length === 7) {
                half1 = postCode.substring(0, 4);
                half2 = postCode.substring(4, 7);
            }
            else if (postCode.length === 6) {
                half1 = postCode.substring(0, 3);
                half2 = postCode.substring(3, 6);
            }
            else if (postCode.length === 5){
            half1 = postCode.substring(0,2);
            half2 = postCode.substring(2,5);
            }

            postCode = half1 + "" + half2;
            Xrm.Page.getAttribute("gcs_postcode").setValue(postCode.replace(postCode));
        alert("You post code isn't in the correct format. it needs to be in the format 'AA11 1AA' ,  where 'A' is a letter, and '1' is a number.");
    }
}


The error message says that an object is expected, and I'm unsure as to whether the "Expecting more source characters" is referring to this as well, or is a separate error.

I know the code is a bit messy and not optimal, and I'll be sorting it once i get it to work properly. I've only started using Javascript in the previous 2 weeks, being more familiar with VB.net, so can't claim to be anything more then a novice.
Any help or suggestions would be greatly appreciated.

Is This A Good Question/Topic? 0
  • +

Replies To: Expecting more source characters

#2 g00se  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2552
  • View blog
  • Posts: 10,636
  • Joined: 20-September 08

Re: Expecting more source characters

Posted 29 August 2013 - 03:20 AM

What exactly does this have to do with Java?
Was This Post Helpful? 0
  • +
  • -

#3 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5949
  • View blog
  • Posts: 23,207
  • Joined: 23-August 08

Re: Expecting more source characters

Posted 29 August 2013 - 03:26 AM

Javascript is NOT java.

Moved to Javascript.
Was This Post Helpful? 1
  • +
  • -

#4 belgarion262  Icon User is offline

  • Prince of all (2) Saiyans

Reputation: 146
  • View blog
  • Posts: 891
  • Joined: 25-October 09

Re: Expecting more source characters

Posted 29 August 2013 - 03:47 AM

View PostJackOfAllTrades, on 29 August 2013 - 04:26 AM, said:

Javascript is NOT java.

Moved to Javascript.


Ack. Apologies.
I can only blame the lack of sleep and general tiredness that afflicts most people who work in IT.
Was This Post Helpful? 0
  • +
  • -

#5 belgarion262  Icon User is offline

  • Prince of all (2) Saiyans

Reputation: 146
  • View blog
  • Posts: 891
  • Joined: 25-October 09

Re: Expecting more source characters

Posted 29 August 2013 - 06:28 AM

View Postbelgarion262, on 29 August 2013 - 04:47 AM, said:

View PostJackOfAllTrades, on 29 August 2013 - 04:26 AM, said:

Javascript is NOT java.

Moved to Javascript.


Ack. Apologies.
I can only blame the lack of sleep and general tiredness that afflicts most people who work in IT.


Can't edit (not enough posts) but to clarify, I simply posted in the wrong forum. I.e. wasn't paying much attention.
Despite my erroneous posting, any help solving my original problem would be appreciated
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1