Expand my Community achievements bar.

SOLVED

"Unable to upload tracking images to the server" in custom form for MMS

Avatar

Level 6

Hi,

We changed the Delivery form slightly in order to link up to 3 images to a delivery. This is used for our MMS text messages: when the delivery is started, a post-processing workflow creates a zip containing a CSV file and the images.

We got the "upload a file" xml form from the standard Public Resources upload form, so it might sound familiar.

Here's our form:

2018-10-17_094131_screen_1.jpg

When we click on "Select Image", we have this window:

2018-10-17_094147_screen_2.jpg

Images are linked to our delivery via an extension of nms:delivery:

2018-10-17_094406_screen_3.jpg

XML of custom:delivery:

<srcSchema desc="Defines the parameters of a delivery (or of a delivery template)."

           entitySchema="xtk:srcSchema" extendedSchema="nms:delivery" img="nms:campaign.png"

           label="Deliveries" labelSingular="Delivery"

           name="delivery" namespace="" xtkschema="xtk:srcSchema">

 

  <element desc="Defines the parameters of a delivery (or of a delivery template)."

           img="nms:campaign.png" label="Deliveries" labelSingular="Delivery" name="delivery">

    <!-- Mobile SMS/MMS -->

    <element label=" Mobile parameters" name="MobileParameters">

      <attribute label="Mobile Object" length="255" name="mobileObject" type="string"/>

      <attribute label="Mobile Callback number" length="255" name="mobileCallbackNumber"

                 type="string"/>

    </element>

    <element label="Image 1" name="image1" revCardinality="single" revExternalJoin="true"

             target="xtk:fileRes" type="link"/>

    <element label="Image 2" name="image2" revCardinality="single" revExternalJoin="true"

             target="xtk:fileRes" type="link"/>

    <element label="Image 3" name="image3" revCardinality="single" revExternalJoin="true"

             target="xtk:fileRes" type="link"/>

  </element>

</srcSchema>

It works fine when we upload 1 image, then save, then close the delivery. However, if we upload 2 images at a time, we have this error:

image.png

Here's our delivery form nms:delivery:

...

<!-- @mobile SMS MMS edit 1 -->

<container label="SMS MMS" ref="custom:deliveryExtensions:mms"/>

<!-- end @mobile SMS MMS edit 1 -->

...

<leave>

...

<!-- @mobile SMS MMS edit 2 -->

    <!-- Addons for mobile extensions. This has to be here -->

    <!-- if mode MMS -->

    <if expr="[smsParameters/@mobileMsgType] = 2 and (@isModel = false or (@isModel = true and [/ignored/tmp/@deliveryRecurring]='1'))">

      <!-- link image 1 to delivery, if any -->

      <if expr="[image1/@fileName] !=''">

        <if expr="[/ignored/writer/fileRes/@internalName]!=''">

          <soapCall name="Write" service="xtk:persist">

            <param exprIn="[/ignored/writer/fileRes]" type="DOMDocument"/>

          </soapCall>

        </if>

        <set value="xtk:fileRes" xpath="/ignored/queryDefFR/@schema"/>

        <set value="select" xpath="/ignored/queryDefFR/@operation"/>

        <set value="@id" xpath="/ignored/queryDefFR/select/node[1]/@expr"/>

        <set expr="'@internalName=\''+[image1/@internalName]+'\''" xpath="/ignored/queryDefFR/where/condition[1]/@expr"/>

        <soapCall name="ExecuteQuery" service="xtk:queryDef">

          <param exprIn="[/ignored/queryDefFR]" type="DOMDocument"/>

          <param type="DOMDocument" xpathOut="/ignored/tmp/operationFR"/>

        </soapCall>

        <set expr="[/ignored/tmp/operationFR/fileRes/@id]" xpath="@image1-id"/>

        <soapCall name="PublishIfNeededFromId" service="xtk:fileRes">

          <param exprIn="[@image1-id]" type="string"/>

        </soapCall>

      </if>

      <!-- link image 2 to delivery, if any -->

      <if expr="[image2/@fileName] !=''">

        <if expr="[/ignored/writer/fileRes/@internalName]!=''">

          <soapCall name="Write" service="xtk:persist">

            <param exprIn="[/ignored/writer/fileRes]" type="DOMDocument"/>

          </soapCall>

        </if>

        <set value="xtk:fileRes" xpath="/ignored/queryDefFR/@schema"/>

        <set value="select" xpath="/ignored/queryDefFR/@operation"/>

        <set value="@id" xpath="/ignored/queryDefFR/select/node[1]/@expr"/>

        <set expr="'@internalName=\''+[image2/@internalName]+'\''" xpath="/ignored/queryDefFR/where/condition[1]/@expr"/>

        <soapCall name="ExecuteQuery" service="xtk:queryDef">

          <param exprIn="[/ignored/queryDefFR]" type="DOMDocument"/>

          <param type="DOMDocument" xpathOut="/ignored/tmp/operationFR"/>

        </soapCall>

        <set expr="[/ignored/tmp/operationFR/fileRes/@id]" xpath="@image2-id"/>

        <soapCall name="PublishIfNeededFromId" service="xtk:fileRes">

          <param exprIn="[@image2-id]" type="string"/>

        </soapCall>

      </if>

      <!-- link image 3 to delivery, if any -->

      <if expr="[image3/@fileName] !=''">

        <if expr="[/ignored/writer/fileRes/@internalName]!=''">

          <soapCall name="Write" service="xtk:persist">

            <param exprIn="[/ignored/writer/fileRes]" type="DOMDocument"/>

          </soapCall>

        </if>

        <set value="xtk:fileRes" xpath="/ignored/queryDefFR/@schema"/>

        <set value="select" xpath="/ignored/queryDefFR/@operation"/>

        <set value="@id" xpath="/ignored/queryDefFR/select/node[1]/@expr"/>

        <set expr="'@internalName=\''+[image3/@internalName]+'\''" xpath="/ignored/queryDefFR/where/condition[1]/@expr"/>

        <soapCall name="ExecuteQuery" service="xtk:queryDef">

          <param exprIn="[/ignored/queryDefFR]" type="DOMDocument"/>

          <param type="DOMDocument" xpathOut="/ignored/tmp/operationFR"/>

        </soapCall>

        <set expr="[/ignored/tmp/operationFR/fileRes/@id]" xpath="@image3-id"/>

        <soapCall name="PublishIfNeededFromId" service="xtk:fileRes">

          <param exprIn="[@image3-id]" type="string"/>

        </soapCall>

      </if>

      <!-- compute content source to tmp var -->

      <set expr="[content/sms/source]" xpath="/tmp/content"/>

      <!-- set computed source to the column "body" -->

      <set expr="[/tmp/content]" xpath="output/extraction/destination/exportColumns/exportColumn[3]/srcScript"/>

    </if>

    <!-- @mobile SMS MMS edit 2 -->

...

</leave>

And here's our form custom:deliveryExtensions:

<form createdBy-id="78015" entitySchema="xtk:form" img="xtk:form.png" label="Delivery (custom extensions)"

      name="deliveryExtensions" namespace="custom" xtkschema="xtk:form"> 

  <!--

      This file is used as an extension in nms:delivery by calling <container label="SMS MMS" ref="custom:deliveryExtensions:mms"/>.

      Some customization are also done at the end of the <leave> tag in nms:delivery

     

      (Please keep this comment for documentation purposes)

  -->

  <!-- SMS MMS Container -->

  <container codepage="1252" label="Message" name="mms" propagateConstraints="false">

    <!-- SMS or MMS -->

    <container codepage="1252" colcount="2" xpath="smsParameters">

      <input checkedValue="0" label="SMS" type="RadioButton" xpath="@mobileMsgType"/>

      <input checkedValue="2" label="MMS" type="radioButton" xpath="@mobileMsgType"/>

    </container>

    <!-- Object and callback -->

    <container codepage="1252" type="visibleGroup" visibleIf="[smsParameters/@mobileMsgType] = 2">

      <input label="Object" xpath="MobileParameters/@mobileObject"/>

    </container>

    <container codepage="1252" type="visibleGroup">

      <input label="Callback" xpath="MobileParameters/@mobileCallbackNumber"/>

    </container>

    <!-- Images-->

    <container codepage="1252" colcount="3" type="visibleGroup" visibleIf="[smsParameters/@mobileMsgType] = 2">

      <!-- Image 1 -->

      <input fontBold="true" img="nl:sryimage.png" label="Select image 1" type="subFormLink"

             xpath="image1">

        <form editionMode="dialog" entitySchema="xtk:form" img="xtk:form.png" label="File resource"

              name="fileRes1" namespace="xtk" xpathsToLoad="@originalName,@fileName,@md5,@contentType,@codepage,@storageType"

              xpathsToLoadOpt="@publish" xtkschema="xtk:form">

          <enter>

            <soapCall name="GetPublicFileResURL" service="xtk:fileRes">

              <param type="string" xpathOut="/tmp/@publicFileResUrl"/>

            </soapCall>

            <if expr="@internalName=''">

              <set expr="GetOption('XtkInstancePrefix')+'RES'+CounterValue('xtkResource')"

                   xpath="@internalName"/>

            </if>

          </enter>

          <!-- Popup -->

          <container codepage="1252" img="xtk:properties.png" label="General" name="selectAnImage">

            <container codepage="1252" colcount="2">

              <input xpath="@label"/>

              <input xpath="@internalName"/>

            </container>

            <container codepage="1252" form="xtk:fileResUpload" name="dropZone" prebuildSubForm="false"

                       type="fileDropZone">

              <enter name="onClick">

                <set expr="[/tmp/@uploadFile]" xpath="@originalName"/>

                <set value="69" xpath="/tmp/@storageType"/>

              </enter>

              <container codepage="1252" label="File" name="actions" type="frame">

                <!-- Container if no file yet -->

                <container codepage="1252" name="upload" type="visibleGroup" visibleIf="@loaded==false">

                  <static img="xtk:loginfo.png" label=" " name="helpNotLoaded">The file has not yet been uploaded on the server. You can drag &amp; drop the file here to upload it, or click on the link below.</static>

                  <input form="xtk:fileResUpload" img="xtk:upload.png" label="Upload file to server..."

                         modelessExpr="'$(entityPath)'='/fileRes'" needWriteAccess="true"

                         type="subFormLink" xpath=".">

                    <enter name="onClick">

                      <set value="5" xpath="/tmp/@storageType"/>

                      <set expr="FileDlg(@originalName, 'open')" xpath="/tmp/@uploadFile"/>

                      <set expr="[/tmp/@uploadFile]" xpath="@originalName"/>

                      <if expr="'$(entityPath)'='/fileRes'">

                        <saveView/>

                      </if>

                    </enter>

                  </input>

                </container>

                <!-- Container if file uploaded -->

                <container codepage="1252" name="loaded" type="visibleGroup" visibleIf="@loaded">

                  <static img="xtk:xtkcheck.png" name="helpLoaded" nolabel="true">The file has been uploaded on the server. You can drag &amp; drop it here, or click on the link below to replace the file.</static>

                  <container codepage="1252" name="download">

                    <input form="xtk:fileResDownload" imgExpr="EImg(@userContentType)"

                           labelExpr="FileName(@originalName)" modelessExpr="'$(entityPath)'='/fileRes'"

                           needWriteAccess="true" nolabel="true" type="fileLink"

                           xpath="."/>

                  </container>

                  <container codepage="1252" name="uploadModify">

                    <input form="xtk:fileResUpload" img="xtk:upload.png" label="Change the file on the server..."

                           modelessExpr="'$(entityPath)'='/fileRes'" needWriteAccess="true"

                           nolabel="true" type="subFormLink" xpath=".">

                      <enter name="onClick">

                        <set value="5" xpath="/tmp/@storageType"/>

                        <set expr="FileDlg(@originalName, 'open')" xpath="/tmp/@uploadFile"/>

                        <set expr="[/tmp/@uploadFile]" xpath="@originalName"/>

                        <if expr="'$(entityPath)'='/fileRes'">

                          <saveView/>

                        </if>

                      </enter>

                    </input>

                  </container>

                </container>

              </container>

            </container>

          </container>

          <!-- On leave -->

          <leave>

            <set value="xtk:fileRes" xpath="../../ignored/writer/fileRes/@xtkschema"/>

            <set value="insert" xpath="../../ignored/writer/fileRes/@_operation"/>

            <if expr="@md5 != ''">

              <set value="insertOrUpdate" xpath="../../ignored/writer/fileRes/@_operation"/>

            </if>

            <set expr="[@fileName]" xpath="../../ignored/writer/fileRes/@fileName"/>

            <set expr="[@md5]" xpath="../../ignored/writer/fileRes/@md5"/>

            <set value="0" xpath="../../ignored/writer/fileRes/@codepage"/>

            <set expr="[@originalName]" xpath="../../ignored/writer/fileRes/@originalName"/>

            <set expr="[@label]" xpath="../../ignored/writer/fileRes/@label"/>

            <set expr="[@internalName]" xpath="../../ignored/writer/fileRes/@internalName"/>

            <set expr="[@contentType]" xpath="../../ignored/writer/fileRes/@contentType"/>

            <set value="1" xpath="../../ignored/writer/fileRes/@useMd5AsFilename"/>

            <!-- set folder -->

            <set value="23352281" xpath="../../ignored/writer/fileRes/@folder_id"/>

          </leave>

        </form>

      </input>

     

      <!-- Image 2 -->

      <container codepage="1252" type="visibleGroup">

        <input fontBold="true" img="nl:sryimage.png" label="Select image 2" type="subFormLink"

               xpath="image2">

          <form editionMode="dialog" entitySchema="xtk:form" img="xtk:form.png" label="File resource"

                name="fileRes2" namespace="xtk" xpathsToLoad="@originalName,@fileName,@md5,@contentType,@codepage,@storageType"

                xpathsToLoadOpt="@publish" xtkschema="xtk:form">

            <enter>

              <soapCall name="GetPublicFileResURL" service="xtk:fileRes">

                <param type="string" xpathOut="/tmp/@publicFileResUrl"/>

              </soapCall>

              <if expr="@internalName=''">

                <set expr="GetOption('XtkInstancePrefix')+'RES'+CounterValue('xtkResource')"

                     xpath="@internalName"/>

              </if>

            </enter>

            <!-- Popup -->

            <container codepage="1252" img="xtk:properties.png" label="General" name="selectAnImage">

              <container codepage="1252" colcount="2">

                <input xpath="@label"/>

                <input xpath="@internalName"/>

              </container>

              <container codepage="1252" form="xtk:fileResUpload" name="dropZone"

                         prebuildSubForm="false" type="fileDropZone">

                <enter name="onClick">

                  <set expr="[/tmp/@uploadFile]" xpath="@originalName"/>

                  <set value="5" xpath="/tmp/@storageType"/>

                </enter>

                <container codepage="1252" label="File" name="actions" type="frame">

                  <!-- Container if no file yet -->

                  <container codepage="1252" name="upload" type="visibleGroup" visibleIf="@loaded==false">

                    <static img="xtk:loginfo.png" label=" " name="helpNotLoaded">The file has not yet been uploaded on the server. You can drag &amp; drop the file here to upload it, or click on the link below.</static>

                    <input form="xtk:fileResUpload" img="xtk:upload.png" label="Upload file to server..."

                           modelessExpr="'$(entityPath)'='/fileRes'" needWriteAccess="true"

                           type="subFormLink" xpath=".">

                      <enter name="onClick">

                        <set value="5" xpath="/tmp/@storageType"/>

                        <set expr="FileDlg(@originalName, 'open')" xpath="/tmp/@uploadFile"/>

                        <set expr="[/tmp/@uploadFile]" xpath="@originalName"/>

                        <if expr="'$(entityPath)'='/fileRes'">

                          <saveView/>

                        </if>

                      </enter>

                    </input>

                  </container>

                  <!-- Container if file uploaded -->

                  <container codepage="1252" name="loaded" type="visibleGroup" visibleIf="@loaded">

                    <static img="xtk:xtkcheck.png" name="helpLoaded" nolabel="true">The file has been uploaded on the server. You can drag &amp; drop it here, or click on the link below to replace the file.</static>

                    <container codepage="1252" name="download">

                      <input form="xtk:fileResDownload" imgExpr="EImg(@userContentType)"

                             labelExpr="FileName(@originalName)" modelessExpr="'$(entityPath)'='/fileRes'"

                             needWriteAccess="true" nolabel="true" type="fileLink"

                             xpath="."/>

                    </container>

                    <container codepage="1252" name="uploadModify">

                      <input form="xtk:fileResUpload" img="xtk:upload.png" label="Change the file on the server..."

                             modelessExpr="'$(entityPath)'='/fileRes'" needWriteAccess="true"

                             nolabel="true" type="subFormLink" xpath=".">

                        <enter name="onClick">

                          <set value="5" xpath="/tmp/@storageType"/>

                          <set expr="FileDlg(@originalName, 'open')" xpath="/tmp/@uploadFile"/>

                          <set expr="[/tmp/@uploadFile]" xpath="@originalName"/>

                          <if expr="'$(entityPath)'='/fileRes'">

                            <saveView/>

                          </if>

                        </enter>

                      </input>

                    </container>

                  </container>

                </container>

              </container>

            </container>

            <!-- On leave -->

            <leave>

              <set value="xtk:fileRes" xpath="../../ignored/writer/fileRes/@xtkschema"/>

              <set value="insert" xpath="../../ignored/writer/fileRes/@_operation"/>

              <if expr="@md5 != ''">

                <set value="insertOrUpdate" xpath="../../ignored/writer/fileRes/@_operation"/>

              </if>

              <set expr="[@fileName]" xpath="../../ignored/writer/fileRes/@fileName"/>

              <set expr="[@md5]" xpath="../../ignored/writer/fileRes/@md5"/>

              <set value="0" xpath="../../ignored/writer/fileRes/@codepage"/>

              <set expr="[@originalName]" xpath="../../ignored/writer/fileRes/@originalName"/>

              <set expr="[@label]" xpath="../../ignored/writer/fileRes/@label"/>

              <set expr="[@internalName]" xpath="../../ignored/writer/fileRes/@internalName"/>

              <set expr="[@contentType]" xpath="../../ignored/writer/fileRes/@contentType"/>

              <set value="1" xpath="../../ignored/writer/fileRes/@useMd5AsFilename"/>

            </leave>

          </form>

        </input>

      </container>

     

      <!-- Image 3 -->

      <container codepage="1252" type="visibleGroup">

        <input fontBold="true" img="nl:sryimage.png" label="Select image 3" type="subFormLink"

               xpath="image3">

          <form editionMode="dialog" entitySchema="xtk:form" img="xtk:form.png" label="File resource"

                name="fileRes3" namespace="xtk" xpathsToLoad="@originalName,@fileName,@md5,@contentType,@codepage,@storageType"

                xpathsToLoadOpt="@publish" xtkschema="xtk:form">

            <enter>

              <soapCall name="GetPublicFileResURL" service="xtk:fileRes">

                <param type="string" xpathOut="/tmp/@publicFileResUrl"/>

              </soapCall>

              <if expr="@internalName=''">

                <set expr="GetOption('XtkInstancePrefix')+'RES'+CounterValue('xtkResource')"

                     xpath="@internalName"/>

              </if>

            </enter>

            <!-- Popup -->

            <container codepage="1252" img="xtk:properties.png" label="General" name="selectAnImage">

              <container codepage="1252" colcount="2">

                <input xpath="@label"/>

                <input xpath="@internalName"/>

              </container>

              <container codepage="1252" form="xtk:fileResUpload" name="dropZone"

                         prebuildSubForm="false" type="fileDropZone">

                <enter name="onClick">

                  <set expr="[/tmp/@uploadFile]" xpath="@originalName"/>

                  <set value="5" xpath="/tmp/@storageType"/>

                </enter>

                <container codepage="1252" label="File" name="actions" type="frame">

                  <!-- Container if no file yet -->

                  <container codepage="1252" name="upload" type="visibleGroup" visibleIf="@loaded==false">

                    <static img="xtk:loginfo.png" label=" " name="helpNotLoaded">The file has not yet been uploaded on the server. You can drag &amp; drop the file here to upload it, or click on the link below.</static>

                    <input form="xtk:fileResUpload" img="xtk:upload.png" label="Upload file to server..."

                           modelessExpr="'$(entityPath)'='/fileRes'" needWriteAccess="true"

                           type="subFormLink" xpath=".">

                      <enter name="onClick">

                        <set value="5" xpath="/tmp/@storageType"/>

                        <set expr="FileDlg(@originalName, 'open')" xpath="/tmp/@uploadFile"/>

                        <set expr="[/tmp/@uploadFile]" xpath="@originalName"/>

                        <if expr="'$(entityPath)'='/fileRes'">

                          <saveView/>

                        </if>

                      </enter>

                    </input>

                  </container>

                  <!-- Container if file uploaded -->

                  <container codepage="1252" name="loaded" type="visibleGroup" visibleIf="@loaded">

                    <static img="xtk:xtkcheck.png" name="helpLoaded" nolabel="true">The file has been uploaded on the server. You can drag &amp; drop it here, or click on the link below to replace the file.</static>

                    <container codepage="1252" name="download">

                      <input form="xtk:fileResDownload" imgExpr="EImg(@userContentType)"

                             labelExpr="FileName(@originalName)" modelessExpr="'$(entityPath)'='/fileRes'"

                             needWriteAccess="true" nolabel="true" type="fileLink"

                             xpath="."/>

                    </container>

                    <container codepage="1252" name="uploadModify">

                      <input form="xtk:fileResUpload" img="xtk:upload.png" label="Change the file on the server..."

                             modelessExpr="'$(entityPath)'='/fileRes'" needWriteAccess="true"

                             nolabel="true" type="subFormLink" xpath=".">

                        <enter name="onClick">

                          <set value="5" xpath="/tmp/@storageType"/>

                          <set expr="FileDlg(@originalName, 'open')" xpath="/tmp/@uploadFile"/>

                          <set expr="[/tmp/@uploadFile]" xpath="@originalName"/>

                          <if expr="'$(entityPath)'='/fileRes'">

                            <saveView/>

                          </if>

                        </enter>

                      </input>

                    </container>

                  </container>

                </container>

              </container>

            </container>

            <!-- On leave -->

            <leave>

              <set value="xtk:fileRes" xpath="../../ignored/writer/fileRes/@xtkschema"/>

              <set value="insert" xpath="../../ignored/writer/fileRes/@_operation"/>

              <if expr="@md5 != ''">

                <set value="insertOrUpdate" xpath="../../ignored/writer/fileRes/@_operation"/>

              </if>

              <set expr="[@fileName]" xpath="../../ignored/writer/fileRes/@fileName"/>

              <set expr="[@md5]" xpath="../../ignored/writer/fileRes/@md5"/>

              <set value="0" xpath="../../ignored/writer/fileRes/@codepage"/>

              <set expr="[@originalName]" xpath="../../ignored/writer/fileRes/@originalName"/>

              <set expr="[@label]" xpath="../../ignored/writer/fileRes/@label"/>

              <set expr="[@internalName]" xpath="../../ignored/writer/fileRes/@internalName"/>

              <set expr="[@contentType]" xpath="../../ignored/writer/fileRes/@contentType"/>

              <set value="1" xpath="../../ignored/writer/fileRes/@useMd5AsFilename"/>

            </leave>

          </form>

        </input>

      </container>

    </container>

  </container>

 

  <!-- on leave the form -->

  <leave name="leave">

    <!--

      customization done directly in nms:delivery,

      because it is not taken into account here.

     (Please keep this comment for documentation purposes)

    -->

  </leave>

</form>

Do you have any idea?

Thank you

1 Accepted Solution

Avatar

Correct answer by
Level 6

It's resolved, we changed it to <input xpath="image1"> <input xpath="image2"> <input xpath="image3"> and it is working fine.

Thank you

View solution in original post

1 Reply

Avatar

Correct answer by
Level 6

It's resolved, we changed it to <input xpath="image1"> <input xpath="image2"> <input xpath="image3"> and it is working fine.

Thank you