Expand my Community achievements bar.

SOLVED

Update iOS push sound parameters for multiple deliveries

Avatar

Level 4

Hi Community! 

I recently updated our iOS app configuration to include a sound for when delivering push messages. This works fine for when I create new deliveries, BUT. We have several continuous deliveries running, where the available sound drop-down is not visible to me. So in order to fix that, apparantly I need to create entirely new deliveries, which seems like a waste of time. 

So I thought I might as well try to update the values through either

  • Mass update selected lines
  • Workflow with update activity
  • JS/SQL queries 

However, I can not choose and update this field from mass update or update activity since it is simply not present for me to choose and update. I am also unsure how I can update this field using JS or SQL. I haven't been succesful yet. Any help in regards to how I can update that 1 field for multiple deliveries would be greatly appreciated!  

Visible from generic query editor:

SorenDahk_0-1675181335472.png

 

Not visible from update element in workflow: 

SorenDahk_1-1675181457109.png

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @SorenDP 

 

this information is not stored an independent field in database but in a XML field.

You can reach this XML via JS, locate your field in a tree, make an update and save XML back to database.

 

You can select all deliveries in the standard query and pass their primary keys to JS node for an update.

Below is code example to update the bounce email in the delivery. Just adapt it for you needs.

 

var query = xtk.queryDef.create(
<queryDef schema={vars.targetSchema} operation="select">
<select>
<node expr="@id"/>
</select>
</queryDef>);
var result = query.ExecuteQuery();


for each (var record in result) {

try {
var delivery = NLWS.nmsDelivery.load(record.@id);
delivery.mailParameters.bounceAddress = 'custom@email.com';
delivery.save()
logInfo ('Succesfull for template: '+record.@id)}
catch (e){
logInfo('Error with template: '+record.@id +' with error: '+e)}

}

 

Cheers,

Milan

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hi @SorenDP 

 

this information is not stored an independent field in database but in a XML field.

You can reach this XML via JS, locate your field in a tree, make an update and save XML back to database.

 

You can select all deliveries in the standard query and pass their primary keys to JS node for an update.

Below is code example to update the bounce email in the delivery. Just adapt it for you needs.

 

var query = xtk.queryDef.create(
<queryDef schema={vars.targetSchema} operation="select">
<select>
<node expr="@id"/>
</select>
</queryDef>);
var result = query.ExecuteQuery();


for each (var record in result) {

try {
var delivery = NLWS.nmsDelivery.load(record.@id);
delivery.mailParameters.bounceAddress = 'custom@email.com';
delivery.save()
logInfo ('Succesfull for template: '+record.@id)}
catch (e){
logInfo('Error with template: '+record.@id +' with error: '+e)}

}

 

Cheers,

Milan

Avatar

Level 4

Thank you very much @Milan_Vucetic ! 


This was exactly what I was looking for. It seems to have solved the underlying issue and I now have sounds on our iOS push messages - Awesome! 

If anyone sees this post and face the same issue, I used this code: 

var query = xtk.queryDef.create(
  <queryDef schema="temp:query3" operation="select">
  <select>
  <node expr="@id"/>
  </select>
  </queryDef>);
var result = query.ExecuteQuery();

for each (var record in result) {

try {
var delivery = NLWS.nmsDelivery.load(record.@id);
delivery.content.iosSound.source = 'default';
//delivery.content.iosAvailableSounds.source = 'default';
delivery.save()
logInfo ('Succesfull for template: '+record.@id)}
catch (e){
logInfo('Error with template: '+record.@id +' with error: '+e)}

}