Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Unable to get xtk:fileRes schema values in webpage

Greeshma_Sampath1
Level 3
Level 3

Hi All,

 

I am creating a web page in which i need to get the images list from public resources folder(xtk:fileRes schema) as drop down so that the customer can select the image from it.

But while adding xtk:fileRes in to the code, the particular column/field is not showing the dropdown option.

For cross checking i used another normal schema and tried and then I was able to get the drop down and the list from that schema was also shown.

Given below the code for this particular field used in the web app:

 

<div class="info">
<div class="infoalign"><b>Image</b><span class="req" id="req_4">*</span></div>
<div class="infowidth"><input name="txtZip" id="pincode" list="imageslist" class="pincode text" type="text" size="14" placeholder="Image" data-nl-ismandatory="true" data-nl-label="Image" data-nl-xpath="@imagepath" data-nl-bindto="xpath" data-validation-type="Image" /></div>
<datalist id="imageslist"><% for each(var rec in new XML(xtk.queryDef.create(<queryDef schema="xtk:fileRes" operation="select" lineCount="100000"> <select> <node expr="@name" alias="name"/> </select> </queryDef>).ExecuteQuery().toXMLString())){ %>
<option value=<%= rec.@name %>>
<% } %>
</datalist>
</div>

 

Is this issue specific to out of the box schemas or xtk schemas?

Could someone kindly help me resolve this issue ASAP.

 

@DavidKangni @Manoj_Kumar_ @wodnicki 

 

Thanks & Regards

Greeshma

0 Replies
Krishnanunni
Level 4
Level 4

Hi @Greeshma_Sampath1 ,

I was able to list the content using querydef inside Javascript code activity. If it works inside the JS activity, I suppose it work on webapp as well. But do you need the toXMLString() and the newXML functions? The execute query itself returns an XML. Following code prints the values of public resources. 

var query = xtk.queryDef.create(  
  <queryDef schema="xtk:fileRes" operation="select">  
     <select>  
      <node expr="@name"/> 
    </select>  
  </queryDef>  
);  
var resultSet =  query.ExecuteQuery();
for each (var row in resultSet) {
  logInfo("Name: "+ row.@name);
}

 

Greeshma_Sampath1
Level 3
Level 3

Hi @Krishnanunni ,

 

Thank you for your suggestion.

I was already able to do the same and got the list in javascript, but the drop down is not coming when it is given in a web page.

Do you have any other idea in which we can achieve this?

 

Thanks & Regards,

Greeshma

MarcelSzimonisz
Community Advisor
Community Advisor

Hello @Greeshma_Sampath1,

you are using alias and calling results by attribute name instead of alias. Remove the alias from your query def

 

Marcel

Greeshma_Sampath1
Level 3
Level 3

Hi @MarcelSzimonisz ,

 

Thank you for your reply.

I have removed alias and tried but still the dropdown was not coming.

 

Thanks&Regards,

Greeshma

MarcelSzimonisz
Community Advisor
Community Advisor

Hi @Greeshma_Sampath1 ,

Looking at your code and you do not need  new XML() in there, as it's adobe campaign document object returned by this query def

 

 

marcel

Greeshma_Sampath1
Level 3
Level 3

Hi @MarcelSzimonisz ,

 

Thank you for your response.

I am able to get the xktfileRes data by using sql select script in page activity.

 

I have a doubt. Can you please tell me how we can take a value from page activity and pass that to the next page activity in a web app in adobe?

The below mentioned is the code i used in page 1 and I need to get the filename to be passed to next page activity to store in a different table.

 

<% var res = sqlSelect("publicUrl,@sstringValue:string",
"select sfilename||',' from xtkfileres where rownum < 10"); for each(var res2 in (res.publicUrl.@sstringValue.toString()).split(','))
{%>

<input name="imageFileres" data-nl-label="Image Path" data-nl-ismandatory="true" type="radio" value="https://redcross-mid-stage3-t.adobe-campaign.com/res/redcros_mid_stage3/<%= res2.split('/usr/local/neolane/nl6/var/res/redcros_mid_prod3/')[1] %>" placeholder="Image path" data-nl-xpath="@imagepath" data-nl-ismandatory="true" data-nl-label="Image path Name" data-nl-bindto="xpath" /></div> />
<img title="American Red Cross - Be a hero to patients in need!a" class="nlui-widget" style="width: 100%; max-width: 600px; height: auto;" src="https://redcross-mid-stage3-t.adobe-campaign.com/res/redcros_mid_stage3/<%= res2.split('/usr/local/neolane/nl6/var/res/redcros_mid_prod3/')[1] %>" unselectable="on" />
<% } %>

 

Thanks & Regards,

Greeshma

MarcelSzimonisz
Community Advisor
Community Advisor

Hello @Greeshma_Sampath1,

similar to workflow you can pass variables via context variable ctx which is available in web app flow.
You can add variable in ctx.vars.xxx and pass it from one place to another. (backend to backend) But to pass user answer use to set it in front end to back end use:

document.controller.setValue('/ctx/webAppLogRcpData/variable');

And on back end use to get it ctx.webAppLogRcpData.variable

Also this variable has to be added in the survey variables in page v5 activity
 
Marcel

 

Greeshma_Sampath1
Level 3
Level 3

Hi @MarcelSzimonisz ,

I have used the below code to get the list from public resources and when one is selected the path/file name gets inserted to the respective @imagepath column in my schema. But the issue is that if i give 3 images in the list and select the 2nd or 3rd image the file name is not getting stored in the column in schema. On the same time when i select the 1st image the path/value is getting stored.

 

<li><% var res = sqlSelect("publicUrl,@sstringValue:string", "select sfilename||',' from xtkfileres where rownum < 3"); for each(var res2 in (res.publicUrl.@sstringValue.toString()).split(',')) {%>
<input name="121212" id="121212" type="radio" value="https://redcross-mid-stage3-t.adobe-campaign.com/res/redcros_mid_stage3/<%= res2.split('/usr/local/neolane/nl6/var/res/redcros_mid_prod3/')[1] %>" label="<%= Math.random() %>" data-nl-bindto="xpath" data-nl-xpath="@imagepath" data-nl-ismandatory="true" data-nl-label="string1" unselectable="on" uselabelasvalue="false" />
<img title="American Red Cross - Be a hero to patients in need!a" class="nlui-widget" style="width: 100%; max-width: 600px; height: auto;" src="https://redcross-mid-stage3-t.adobe-campaign.com/res/redcros_mid_stage3/<%= res2.split('/usr/local/neolane/nl6/var/res/redcros_mid_prod3/')[1] %>" unselectable="on" /> <% } %></li>

 

Could you please help me in this ASAP.

 

Thanks & regards,

Greeshma