Formatting a calculation field - combining '1,2,3' with 'A' but listing it '1A 2A 3A' instead of ,'1,2,3A'

Comments

8 comments

  • Rainer Grabowski

    Hi Rachel, 

    If I understand you right, you have app A where a field with a booking reference (1239) is in. This app has a relationship field to or is referenced by app B where in one field the band name is in. In your example the app A item is related to 3 app B items (3 bands, item 1: Band A, item 2: Band B, item 3: Band C). The calculation field where you want the result  1239 Band A,1239 Band B,1239 Band C is in app A. Is that correct?

    If it is correct enter the calculation:

    var band = @all of field where the band name is in;
    var ref = @field where booking reference is in;
    var result = [];
    for(var i = 0; i < band.length; i++){
    result.push(ref + " " + band[i]);
    };
    result.join()

    Rainer

    0
    Comment actions Permalink
  • Rachel Gretton

    Thanks Rainer but it might be slightly more complicated because my relationship field is linked to 4 apps - Act Name, Supplier Name and Exclusive Act Name. So would this change it?

    Currently I have a calculation field called Act Supplier/ Name (Calc) like this: 

    var ex = @All of Exclusive Act Name + " ";
    var act = @All of Act Name + " ";
    var sup = @All of Supplier Name + " ";
    ex+act+sup

    Which gives me a result of: DJ K-BYRNE,DJ Malin,The Kings

    and then another calculation field called Booking Code like this:

    @All of Booking No.+ @Act Supplier/ Name (Calc)

    Which gives me a result of: 1386DJ K-BYRNE,DJ Malin,The Kings

    I need it to say: 1386 DJ K-BYRNE,1386 DJ Malin, 1386 The Kings

    I hope that makes sense

    0
    Comment actions Permalink
  • Kareem Ahmed Asfour

    Hello @Rachel Gretton

    you can do it with this method. check screenshots.

     

     

    2- Code.

     

     

     

    Contact me if you have any questions.

    Skype: Kareem-asfour@hotmail.com

    Thanks

    0
    Comment actions Permalink
  • Kareem Ahmed Asfour

    if it linked to 4 apps try this code :

     

    var ex = @All of Exclusive Act Name + " ";
    var act = @All of Act Name + " ";
    var sup = @All of Supplier Name + " ";

    @Booking No+" "+ex+@Booking No+" "+act+@Booking No+" "+sup

     

     

     

     

    0
    Comment actions Permalink
  • Rainer Grabowski

    Hello Rachel,

    there are multiple ways to achieve that. One is:

    var bn = @All of Booking No..toString();
    var asn = @Act Supplier/ Name (Calc).split(",");
    var result = [];
    for(var i = 0; i < asn.length; i++){
    result.push(bn + " " + asn[i]);
    };
    result.join()

    Another one:

    var bn = @All of Booking No..toString();
    var ex = bn + " " + @All of Exclusive Act Name.toString();
    var act = bn + " " + @All of Act Name.toString();
    var sup = bn + " " + @All of Supplier Name.toString();
    ex+act+sup

    Rainer

    0
    Comment actions Permalink
  • Rachel Gretton

    Thanks both but unfortunately neither of these suggestions work if for example, I have more than one band from a referenced app.

    Band A (From Exclusive Act)
    Band B (From Exclusive Act)
    Band C (From Supplier App)

    Gives me a result of: 1239 Band, Band B 1239 Band C

    0
    Comment actions Permalink
  • Rainer Grabowski

    Hi Rachel, 
    in your examüel the band names have been pulled via 3 different relationships. But to cover all possiblities: 

    var a = @all of whatever field;
    var b = @all of another field;
    var c = @all of a third field;
    var ref = @field where booking reference is in;
    var bands = a.concat(b,c).join().split(",");
    var result = [];
    for(var i = 0; i < band.length; i++){
    result.push(ref + " " + band[i]);
    };
    result.join()

    Rainer

    0
    Comment actions Permalink
  • Rachel Gretton

    Thanks Rainer that works!

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk