Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.23 KB | None | 0 0
  1. /***********************Dependency List************************* **/
  2. //Dependency JSON
  3. var product1 = {
  4. "Alibaba groß Rapspalette": ["Alibaba groß Rapspalette","01u1o00000OuSj0AAF"],
  5. "One": ["One"],
  6. "test": ["test"],
  7. "Amazon.de Gutschein 25 Euro": ["Amazon.de Gutschein 25 Euro", "01u1w000003n5CaAAI"]
  8. }
  9.  
  10. var oli_unit_price = {
  11. "Alibaba groß Rapspalette": ["12"],
  12. "One": ["13"],
  13. "test": ["13"],
  14. "Amazon.de Gutschein 25 Euro": ["14"]
  15. }
  16. var order_unit_price = {
  17. "Alibaba groß Rapspalette": ["30"],
  18. "One": ["31"],
  19. "test": ["32"],
  20. "Amazon.de Gutschein 25 Euro": ["33"]
  21. }
  22.  
  23.  
  24.  
  25.  
  26. // //Repeat group event on adding the record
  27. // formyoula.form_fields["f7e2-c61c-8a3a"].on("input:set:success",function(event_name) {
  28. // console.log('Outside IF===');
  29. // if ( this.get("repeat_value").length ) {
  30. // var repeat_id = this.get("component_id");
  31. // this.get("repeat_value").forEach(function(repeat_group, index) {
  32. // //Get current value for OLI price book id
  33. // var selected_option = _.find(repeat_group, function(element) {
  34. // return element.component_id == "6ee2-acfd-2e89"
  35. // })
  36. // selected_option = selected_option.value;
  37. // //Looop for component data
  38. // _.filter(repeat_group, function(element) {
  39. // //Check if type is Salesforce and null value or no value available
  40. // console.log('Outside IF===');
  41. // /****************Code for the picklist****************/
  42. // //Set the picklist id to text field
  43. // if (element.component_id == "4392-e578-b146" ) {
  44. // //Get the id of selected picklist value
  45. // var selected_picklist_id = product1[selected_option] && product1[selected_option][1] ? product1[selected_option][1] : '';
  46. // console.log(selected_picklist_id)
  47. // element.value = selected_picklist_id;
  48. // }
  49. // //Set the valut to second picklist - Order PBI
  50. // if ( element.component_id == "49b8-df0d-2c75" ) {
  51. // var dependent_picklist = product1[selected_option] ? product1[selected_option][0] : '';
  52. // element.value = dependent_picklist;
  53. // $("#collapse_"+repeat_id+"_"+index+" #component-"+element.component_id+" .input_content").val(dependent_picklist);
  54. // }
  55. // if ( element.component_id == "e255-3f8c-28b5" ) {
  56. // //order Price
  57. // var order_price = order_unit_price[selected_option] ? order_unit_price[selected_option][0] : '';
  58. // element.value = order_price;
  59. // $("#collapse_"+repeat_id+"_"+index+" #component-"+element.component_id+" .input_content").val(order_price);
  60. // }
  61. // if ( element.component_id == "3969-7298-147b" ) {
  62. // //Unit Price
  63. // var unit_price = oli_unit_price[selected_option] ? oli_unit_price[selected_option][0] : '';
  64. // element.value = unit_price;
  65. // $("#collapse_"+repeat_id+"_"+index+" #component-"+element.component_id+" .input_content").val(unit_price);
  66. // }
  67. // })
  68. // })
  69. // }
  70. // })
  71. //Event on change the select list element
  72. formyoula.form_fields["6ee2-acfd-2e89"].on("input:set:success",function(){
  73. console.log('Inside==');
  74. // Check input( $( this ).val() ) for validity here
  75. var selected_option = this.get("value");
  76. //Product/OLI Price book ID
  77. var dependent_picklist = product1[selected_option] ? product1[selected_option][0] : '';
  78. //order Price
  79. var order_price = order_unit_price[selected_option] ? order_unit_price[selected_option][0] : '';
  80. //Unit Price
  81. var unit_price = oli_unit_price[selected_option] ? oli_unit_price[selected_option][0] : '';
  82. //Get id of selected picklist
  83. var selected_picklist_id = product1[selected_option] && product1[selected_option][1] ? product1[selected_option][1] : '';
  84. //Added by pramod
  85. // window.formyoula.form_fields["f7e2-c61c-8a3a"].get('repeat_value')[repeat_index][3].value = dependent_picklist;
  86. // Added by the pramod
  87. // win/dow.formyoula.form_fields["f7e2-c61c-8a3a"].get('repeat_value')[repeat_index][5].value = order_price;
  88. // window.formyoula.form_fields["f7e2-c61c-8a3a"].get('repeat_value')[repeat_index][6].value = unit_price;
  89. //Ended by the pramod
  90. //Set id of select picklist
  91. formyoula.form_fields["4392-e578-b146"].set({"value": selected_picklist_id});
  92. //dependent picklist
  93. formyoula.form_fields["49b8-df0d-2c75"].set({"value": dependent_picklist});
  94. //Order price
  95. formyoula.form_fields["e255-3f8c-28b5"].set({"value": order_price});
  96. //Unit Price
  97. formyoula.form_fields["3969-7298-147b"].set({"value": unit_price});
  98. });
  99.  
  100.  
  101. //Event for pre-fill success.
  102. formyoula.form_fields['f7e2-c61c-8a3a'].on('prefill:success',function(){
  103. //Loop for repeat index
  104. for (var repeat_index=0; repeat_index < window.formyoula.form_fields["f7e2-c61c-8a3a"].get('repeat_value').length; repeat_index++ ) {
  105. //Looop for component data
  106. for ( var i_component = 0; i_component < window.formyoula.form_fields["f7e2-c61c-8a3a"].get('repeat_value')[repeat_index].length; i_component++ ) {
  107. //Check if type is Salesforce and null value or no value available
  108. /****************Code for the picklist****************/
  109. if ( window.formyoula.form_fields["f7e2-c61c-8a3a"].get('repeat_value')[repeat_index][i_component].label == "OLI Price book ID" ) {
  110. //Get selected product
  111. var selected_product = window.formyoula.form_fields["f7e2-c61c-8a3a"].get('repeat_value')[repeat_index][i_component].value;
  112. //Check if dependent picklist available.
  113. if ( product1[selected_product] ) {
  114. window.formyoula.form_fields["f7e2-c61c-8a3a"].get('repeat_value')[repeat_index][3].value = product1[selected_product][0];
  115. //Get the select picklist id
  116. window.formyoula.form_fields["f7e2-c61c-8a3a"].get('repeat_value')[repeat_index][4].value = product1[selected_product][1] ? product1[selected_product][1] : '';
  117.  
  118. //Update UI of the form
  119. $('#collapse_f7e2-c61c-8a3a_'+repeat_index+' #component-49b8-df0d-2c75 .input_content').val(product1[selected_product][0])
  120.  
  121. //Update UI of the form
  122. $('#collapse_f7e2-c61c-8a3a_'+repeat_index+' #component-4392-e578-b146 .input_content').val(product1[selected_product][1] ? product1[selected_product][1] : '');
  123. }
  124. }
  125. }
  126. }
  127. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement