dymosoftware / DCD-SDK-Sample

DYMO Connect SDK Samples
Other
60 stars 27 forks source link

dymo.connect.framework.js does not support setting text for a QRCode object #12

Closed hewisaurus closed 3 years ago

hewisaurus commented 4 years ago

When creating a label in Dymo Connect, all works as expected when using the JS framework except using setObjectText on a QRCode object - the JS is missing the switch case for QRCodeObject.

Current switch:

dymo.label.framework.Label.prototype.setObjectText = function(e, o) {
    var t = this._getObjectByNameElement(e);
    switch (t.tagName) {
        case "AddressObject":
        case "TextObject":
            this._setAddressObjectText(t, o);
            break;
        case "BarcodeObject":
            this._setBarcodeObjectText(t, o);
            break;
        case "ImageObject":
            this._setImageObjectText(t, o);
            break;
        case "CircularTextObject":
            this.isDCDLabel() ? this._setAddressObjectText(t, o) : dymo.xml.setElementText(dymo.xml.getElement(t, "Text"), o);
            break;
        case "DateTimeObject":
        case "CounterObject":
            this._setDateTimeCounterObjectText(t, o)
    }
    return this
}

The framework is also missing a matching a _setQRCodeObjectText() function, similar to the one for barcode (_setBarcodeObjectText())

dymosoftware commented 3 years ago

Hi @hewisaurus, setting the text for QRCode objects is not supported on DYMO Connect Framework since DYMO Label and DYMO Connect WebService does not support this feature. We'll keep in mind to include this feature ONLY for DYMO Connect since we are focused on this product.

giuliodamato commented 3 years ago

dear @hewisaurus, this problem has been driving me crazy all day yesterday!

I understood that something was messed up in the framework only thanks to this issue, it was impossible to find out from the original documentation that it was not possible to set the text of a QR Code.

I really can't understand why, since there are even some examples about it on the dymo blog. However, the solution has been quite straightforward, I post it here just in case someone needs it.

Added the case in the switch:

dymo.label.framework.Label.prototype.setObjectText = function(e, o) {
  var t = this._getObjectByNameElement(e);
  switch (t.tagName) {
    case "AddressObject":
    case "TextObject":
        this._setAddressObjectText(t, o);
        break;
    case "QRCodeObject":
        this._setQRCodeObjectText(t, o);
        break;
    case "BarcodeObject":
        this._setBarcodeObjectText(t, o);
        break;
    case "ImageObject":
        this._setImageObjectText(t, o);
        break;
    case "CircularTextObject":
        this.isDCDLabel() ? this._setAddressObjectText(t, o) : dymo.xml.setElementText(dymo.xml.getElement(t, "Text"), o);
        break;
    case "DateTimeObject":
    case "CounterObject":
        this._setDateTimeCounterObjectText(t, o)
  }
  return this
}

Added the following function:

dymo.label.framework.Label.prototype._setQRCodeObjectText = function(e, o) {
  if (this.isDCDLabel()) {
    var t = dymo.xml.getElement(e, "Data")
      , r = dymo.xml.getElement(t, "DataString");

    dymo.xml.setElementText(r, o);

    var t = dymo.xml.getElement(e, "TextDataHolder")
      , r = dymo.xml.getElement(t, "Value");

    dymo.xml.setElementText(r, o);
  }
  return this
}

Hope this helps, @dymosoftware it's a minor mod that actually changes a lot!

Cheers, Giulio

EDIT: I forked the repo and added the fix :) https://github.com/giuliodamato/dymo-connect-framework

hunkydoryrepair commented 3 years ago

Hi @hewisaurus, setting the text for QRCode objects is not supported on DYMO Connect Framework since DYMO Label and DYMO Connect WebService does not support this feature. We'll keep in mind to include this feature ONLY for DYMO Connect since we are focused on this product.

This response doesn't make much sense. The text can be changed before sending to the webservice, and a simple javascript solution has been provided.

Fock3 commented 3 years ago

dear @hewisaurus, this problem has been driving me crazy all day yesterday!

I understood that something was messed up in the framework only thanks to this issue, it was impossible to find out from the original documentation that it was not possible to set the text of a QR Code.

I really can't understand why, since there are even some examples about it on the dymo blog. However, the solution has been quite straightforward, I post it here just in case someone needs it.

Added the case in the switch:

dymo.label.framework.Label.prototype.setObjectText = function(e, o) {
  var t = this._getObjectByNameElement(e);
  switch (t.tagName) {
    case "AddressObject":
    case "TextObject":
        this._setAddressObjectText(t, o);
        break;
    case "QRCodeObject":
        this._setQRCodeObjectText(t, o);
        break;
    case "BarcodeObject":
        this._setBarcodeObjectText(t, o);
        break;
    case "ImageObject":
        this._setImageObjectText(t, o);
        break;
    case "CircularTextObject":
        this.isDCDLabel() ? this._setAddressObjectText(t, o) : dymo.xml.setElementText(dymo.xml.getElement(t, "Text"), o);
        break;
    case "DateTimeObject":
    case "CounterObject":
        this._setDateTimeCounterObjectText(t, o)
  }
  return this
}

Added the following function:

dymo.label.framework.Label.prototype._setQRCodeObjectText = function(e, o) {
  if (this.isDCDLabel()) {
    var t = dymo.xml.getElement(e, "Data")
      , r = dymo.xml.getElement(t, "DataString");

    dymo.xml.setElementText(r, o);

    var t = dymo.xml.getElement(e, "TextDataHolder")
      , r = dymo.xml.getElement(t, "Value");

    dymo.xml.setElementText(r, o);
  }
  return this
}

Hope this helps, @dymosoftware it's a minor mod that actually changes a lot!

Cheers, Giulio

EDIT: I forked the repo and added the fix :) https://github.com/giuliodamato/dymo-connect-framework

Welcome, how to add it to existing installation of Dymo Connect? I fighting with this issue over 2 months and also support don't know how to help me. We just need at QR code clear "TEXT" without any ads "URL:" etc. Regards

dymosoftware commented 3 years ago

A fix was already merged into the script. See this PR https://github.com/dymosoftware/dymo-connect-framework/pull/17.

Fock3 commented 3 years ago

A fix was already merged into the script. See this PR dymosoftware/dymo-connect-framework#17.

Welcome, Then how to use it in Dymo Connect? How to add this new script to already existing installation of Dymo Connect?

giuliodamato commented 3 years ago

A fix was already merged into the script. See this PR dymosoftware/dymo-connect-framework#17.

Welcome, Then how to use it in Dymo Connect? How to add this new script to already existing installation of Dymo Connect?

Dear @Fock3, the problem that you are facing is not related to this issue.

From what I understand (based on the email you sent me) when you import QR code values from Excel spreadsheets, Dymo Connect software changes the QR code type from Text to Web Page (adding the "URL:" characters).

This seems a bug of the Dymo Connect software (I tried it myself and it behaves the same way you say), however this issue was all about the framework to implement 3rd party software that prints labels (and not the original Dymo Connect software).

Cheers, Giulio :)

ps. @dymosoftware: nice to be merged into your repo 👍

dymosoftware commented 3 years ago

Dear @Fock3, as @giuliodamato mentioned, your issue is related to DYMO Connect Software. Please, contact our Consumer Care team(dymoconsumercare@newellco.com) to collect more information and take action about this issue.

Fock3 commented 3 years ago

(dymoconsumercare@newellco.com)

Thank you, will do it.

rkalman commented 2 years ago

Finally I found this thread, and unfortunately DYMO Connect for Desktop v1.4.3 - still no luck.

giuliodamato commented 2 years ago

Finally I found this thread, and unfortunately DYMO Connect for Desktop v1.4.3 - still no luck.

Hi, what is the problem that you are facing?

rkalman commented 2 years ago

It is not related to the js framework but the Demo connect software. I wanted to generate a series of QR codes each contains a text coming from a data source (xls,csv). As it is described above the QR code type always changed back from "text" to "website", and the prefix URL: is added. So nothing changed in the last few months, we have the same behaviour in the recent version of Dymo Connect like before.

ertoorule commented 2 years ago

nobody cares about this problem? still exist on 1.4.3.131

hunkydoryrepair commented 2 years ago

nobody cares about this problem? still exist on 1.4.3.131

This issue is closed. idk what 1.4.3.131 even refers to, but this project is the javascript interface to the Dymo web service. You can set text for a QR Code through this javascript library with no issue. If you have an issue with the Dymo Connect client, contact their customer service. They developers do not monitor this project.

aaron-neal commented 2 years ago

I am not 100% sure that this is solved. I have used the latest framework in this repo and the QR would not change until I used the function supplied by @giuliodamato. It seems that the TextDataHolder element needs changing as well.

Below is the adapted function that works for me, without this, my QR is still the same as what I designed in the DYMO connect desktop software.

 dymo.label.framework.Label.prototype._setQRCodeObjectText = function(objectElem, text) {
     if (this.isDCDLabel()) {
         var dataElem = dymo.xml.getElement(objectElem, "Data");
         if (dataElem) {
             var dataStringElem = dymo.xml.getElement(dataElem, "DataString");
             dymo.xml.setElementText(dataStringElem, text);
         }
         dataElem = dymo.xml.getElement(objectElem, "TextDataHolder");
         if (dataElem) {
             var dataStringElem = dymo.xml.getElement(dataElem, "Value");
             dymo.xml.setElementText(dataStringElem, text);
         }
     }
     return this;
 }
hvt commented 1 year ago

Thank you very much @porkyneal , that indeed fixed my problem!

@dymosoftware this is definitely PR material, are you accepting PRs on this repo?