Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
2.6 kB
2
Indexable
Never
newLookUpCodeMultipleOtherClients(name, value) {
    let abcArr1 = [];
    this.subLocationLookup = [];
    for (let j = 0; j < this.fields.length; j++) {

      if (this.fields[j].lookup.view !== undefined) {

        abcArr1.push(this.lookupdata);

        for (let g = 0; g < abcArr1.length; g++) {

          for (let h = 0; h < abcArr1[g].lookupdc.length; h++) {

            if (abcArr1[g].lookupdc[h].vname === this.fields[j].lookup.view) {
              let col1Arr = [];
              let col2Arr = [];
              let newSublocationArr = [];
              let postCodeArr = [];

              for (let k = 0; k < abcArr1[g].lookupdc[h].data.length; k++) {

                if (abcArr1[g].lookupdc[h].data[k].COL_0 === value) {
                  //col1Arr.push(abcArr1[g].lookupdc[h].data[k].COL_1);
                  col1Arr.push({ 'text': abcArr1[g].lookupdc[h].data[k].COL_1, 'value': abcArr1[g].lookupdc[h].data[k].COL_1 });
                  col2Arr.push({ 'text': abcArr1[g].lookupdc[h].data[k].COL_2, 'value': abcArr1[g].lookupdc[h].data[k].COL_2 });

                  col1Arr = col1Arr.filter((el, i, a) => i === a.indexOf(el));
                  col2Arr = col2Arr.filter((el, i, a) => i === a.indexOf(el));

                  newSublocationArr = col1Arr.filter((el, i, a) => i === a.indexOf(el));
                  postCodeArr = col2Arr.filter((el, i, a) => i === a.indexOf(el));

                  let test = this.removeDuplicates(newSublocationArr, 'text');
                  let test1 = this.removeDuplicates(postCodeArr, 'text'); //for post code

                  let pfieldId = this.sectionType.secId + '_' + this.fields[j + 1].lookup.pfieldid;
                  console.log("NAME OF FIELD FOR LOOKUP",this.fields[j+2].name,pfieldId,this.fields[j + 1].lookup.pfieldid,this.fields[j + 1]);
                  if(this.fields[j + 2].name === 'AIR_II1_II_BT_Site_Town'){ //hardcode for bt

                  for(let i= 0;i<20;i++){
                    if(this.fields[j + i].label === 'BT Site post code' || this.fields[j + 1].name.includes('AIR_II1_II_BT_Site_Add')){
                      this.fields[j + i].value = test1[0].text;
                    }
                    if(this.fields[j + i].label === 'BT Site Town'){
                      this.fields[j + i].value = test[0].text;
                    }
                  }

                  }

                }
              }

            
            }
          }
        }
        break;
      }

      else {
        // console.log("no look up for this field", this.fields[j].lookup.view);
      }
    }

  }