<div dir="ltr"><div>Okay, gang. I'm missing something and it's probably obvious to someone more familiar with chained functions and scope, but I can't figure it out. After trying a bunch of different approaches, this is the closest I've been able to get. It's writing the correct value to the console log, but it is displaying the *previous* value in the interface. Argh. See video demo of the problem:</div><div><br></div><div><a href="https://screencast-o-matic.com/watch/cr1bDNV16uo">https://screencast-o-matic.com/watch/cr1bDNV16uo</a></div><div><br></div><div>
********** <br></div><div><br></div><div> $scope.local_overlay_target = egCore.hatch.getLocalItem('eg.cat.marked_overlay_record') || 0;<br> if($scope.local_overlay_target) {<br> var currTarget = $scope.local_overlay_target;<br> <b> $scope.local_overlay_target_tcn = get_tcn(currTarget);</b><br> }<br> $scope.mark_as_overlay_target = function() {<br> var items = $scope.gridControls.selectedItems();<br> if ($scope.local_overlay_target == items[0]['bibid']) {<br> $scope.local_overlay_target = 0;<br> $scope.local_overlay_target_tcn = 0;<br> } else {<br> $scope.local_overlay_target = items[0]['bibid'];<br> var currTarget = items[0]['bibid'];<br> <b>$scope.local_overlay_target_tcn = get_tcn(currTarget);</b><br> }<br> egCore.hatch.setLocalItem('eg.cat.marked_overlay_record',$scope.local_overlay_target);<br> }</div><div><br></div><div><b> function get_tcn(currTarget) {<br> egCore.pcrud.retrieve('bre', currTarget, {<br> select: {bre: ['tcn_value']}<br> }).then(function(rec) {<br> $scope.thisTCN = rec.tcn_value();<br> console.log("TEST: " + $scope.thisTCN);<br> });<br> return $scope.thisTCN;<br> };</b></div><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><br></div><div>**********</div><div><br></div><div>This writes the correct TCN value to the console, but it does not always load that value to $scope.local_overlay_target_tcn. If I have an item marked for overlay and I load the page, it displays the correct TCN. But, if I use the interface to select a different item, it keeps the original TCN in the display. <br></div><div><br></div><div>When I tried setting a regular variable (instead of a $scope variable) in the "then" part of the chained function, I couldn't access it from outside that part of the function. Am I creating the thisTCN variable wrong? Or returning it wrong? Or ... ???<br></div><div><br></div><div><br></div><div><div dir="ltr" style="margin-left:0pt"><table style="border:medium none;border-collapse:collapse"><colgroup><col width="94"><col width="530"></colgroup><tbody><tr style="height:123pt"><td style="vertical-align:top;padding:5pt"><p dir="ltr" style="line-height:1.2;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap"><span style="border:none;display:inline-block;overflow:hidden;width:75px;height:75px"><img src="https://lh6.googleusercontent.com/fJoF6o0xl9XByQZmykva1sv2n_cKGUXL_BH4crkpJgSqDu-yU7-5jIypuXBsEuoXCCBAAUQ2jUztJlZDNUVOlwl1bWZIL1W4wmFuEEzCLVMxUyhzdkV7jkcRcdZZni2z8OPz4xJA" style="margin-left:0px;margin-top:0px" width="75" height="75"></span></span></p></td><td style="vertical-align:top;padding:5pt"><p dir="ltr" style="line-height:1.2;margin-top:0pt;margin-bottom:0pt;margin-left:9pt"><span style="font-size:11pt;font-family:Verdana;color:rgb(30,67,155);background-color:transparent;font-weight:700;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Terran McCanna, PINES Program Manager</span></p><hr><p dir="ltr" style="line-height:1.2;margin-top:0pt;margin-bottom:0pt;margin-left:9pt"><span style="font-size:10pt;font-family:Verdana;color:rgb(0,0,0);background-color:transparent;font-weight:700;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"></span><span style="font-size:9pt;font-family:Verdana;color:rgb(30,67,155);background-color:transparent;font-weight:700;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Georgia Public Library Service | University System of Georgia</span></p><p dir="ltr" style="line-height:1.2;margin-top:0pt;margin-bottom:0pt;margin-left:9pt"><span style="font-size:9pt;font-family:Verdana;color:rgb(30,67,155);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">2872 Woodcock Blvd, Suite 250 l Atlanta, GA 30341</span></p><p dir="ltr" style="line-height:1.2;margin-top:0pt;margin-bottom:0pt;margin-left:9pt"><span style="font-size:9pt;font-family:Verdana;color:rgb(30,67,155);background-color:rgb(255,255,255);font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">(404) 235-7138</span><span style="font-size:9pt;font-family:Verdana;color:rgb(30,67,155);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"> | <a href="mailto:tmccanna@georgialibraries.org" target="_blank">tmccanna@georgialibraries.org</a> <br></span></p><p dir="ltr" style="line-height:1.2;margin-top:0pt;margin-bottom:0pt;margin-left:9pt"><span style="font-size:9pt;font-family:Verdana;color:rgb(30,67,155);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><a href="http://help.georgialibraries.org" target="_blank">http://help.georgialibraries.org</a> | <a href="mailto:help@georgialibraries.org" target="_blank">help@georgialibraries.org</a><br></span></p><br><p dir="ltr" style="line-height:1.2;margin-top:0pt;margin-bottom:0pt;margin-left:9pt"><a href="https://www.facebook.com/georgialibraries" style="text-decoration:none" target="_blank"><span style="font-size:9pt;font-family:Verdana;color:#1155cc;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline;white-space:pre;white-space:pre-wrap"><span style="border:none;display:inline-block;overflow:hidden;width:36px;height:36px"><img src="https://lh4.googleusercontent.com/77DYzuoZ-zqC0pyQuYNKCrWaPuOANHsYTJze0JxE_iK4yW2sCswywdPCC8hCHOIyhO7KKIO-L6dlN1wIqdHFcyJmTa1fuc5Ok34dR8FQTtZHawpgNmovGxjg9RS0-WI74dFDHw0_" style="margin-left:0px;margin-top:0px" width="36" height="36"></span></span></a><a href="https://www.twitter.com/georgialibs" style="text-decoration:none" target="_blank"><span style="font-size:10pt;font-family:Verdana;color:#1155cc;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline;white-space:pre;white-space:pre-wrap"><span style="border:none;display:inline-block;overflow:hidden;width:35px;height:35px"><img src="https://lh4.googleusercontent.com/1bKX66xWgHe-v5FD5l-hYX4FrZDXi1Y2aKr0DZLDA_oEHy7s01WVqgVilQcwGBzRQZAg3yOePmZncGwtiYGSgavOkb0T5Tj3c46iUJ7ZE7h-MUEhVwXQs7Oc3cahIYMN2SGlk_6b" style="margin-left:0px;margin-top:0px" width="35" height="35"></span></span></a><a href="https://www.instagram.com/georgialibraries/" style="text-decoration:none" target="_blank"><span style="font-size:11pt;font-family:Verdana;color:#1155cc;background-color:transparent;font-weight:700;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline;white-space:pre;white-space:pre-wrap"><span style="border:none;display:inline-block;overflow:hidden;width:34px;height:34px"><img src="https://lh3.googleusercontent.com/U7PH5YIQnuRvbeMnGOlJAEPAre7Zqx_I6IDJAtJVwUDCp1-TmjSwP_x21qKx8ApsbcaILIuSpL3Pzau2Rz-phR_4IPcLR4LrIha_JMDHqombNtsfa1uhXcYS02QWTAyYqSf3ES_n" style="margin-left:0px;margin-top:0px" width="34" height="34"></span></span></a><a href="https://www.twitter.com/georgialibs" style="text-decoration:none" target="_blank"><span style="font-size:10pt;font-family:Verdana;color:rgb(17,85,204);background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap"></span></a></p></td></tr><tr style="height:21pt"><td colspan="2" style="vertical-align:top;padding:5pt"><p dir="ltr" style="line-height:1.2;margin-top:0pt;margin-bottom:0pt;text-align:center"><a href="http://georgialibraries.org" style="text-decoration:none" target="_blank"><span style="font-size:10pt;font-family:Verdana;color:rgb(17,85,204);background-color:rgb(255,255,255);font-weight:400;font-style:italic;font-variant:normal;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap">Join our email list</span></a><span style="font-size:10pt;font-family:Verdana;color:rgb(0,0,0);background-color:rgb(255,255,255);font-weight:400;font-style:italic;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"> </span><span style="font-size:10pt;font-family:Verdana;color:rgb(67,67,67);background-color:rgb(255,255,255);font-weight:400;font-style:italic;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">for stories of Georgia libraries making an impact in our communities.</span></p></td></tr></tbody></table></div><br></div></div></div></div></div></div></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jun 16, 2021 at 4:36 PM Josh Stompro via Eg-newdevs <<a href="mailto:eg-newdevs@list.evergreen-ils.org">eg-newdevs@list.evergreen-ils.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Terran, I think the get_tcn function is in scope... it just doesn't return a value. I followed the code in the developer console and it does grab the tcn.<div><br></div><div>The function sets the $scope.local_overlay_target_tcn to be equal to the found tcn value. But it doesn't return it.</div><div><br></div><div> function get_tcn(currTarget) {<br> egCore.pcrud.retrieve('bre', currTarget, {<br> select: {bre: ['tcn_value']}<br> }).then(function(rec) {<br> $scope.local_overlay_target_tcn = rec.tcn_value();<br> });<br> return;<br> };</div><div><br></div><div>Maybe the function should just return the value... and then instead of just calling it like</div><div><br></div><div> } else {<br> $scope.local_overlay_target = items[0]['bibid'];<br> var currTarget = items[0] ['bibid'];<br> get_tcn(currTarget);<br> }</div><div><br></div><div>You would use</div><div><br></div><div> } else {<br> $scope.local_overlay_target = items[0]['bibid'];<br> var currTarget = items[0] ['bibid'];<br> $scope.local_overlay_target_tcn = get_tcn(currTarget);<br> }</div><div><br></div><div>Josh</div><div><div><div dir="ltr"><table style="padding:0px;margin:10px 0px;border:medium none"><tbody><tr><td style="vertical-align:middle;padding:0px 7px 0px 0px"><img alt="Company logo" src="https://storage.googleapis.com/signaturesatori/customer-C039u5c5y/images/GJnfy.png" width="100" height="100"></td><td style="border-left:3px solid rgb(232,232,232);padding:7px 0px 0px 10px">
<div style="font-family:"arial","helvetica",sans-serif;font-size:14px;line-height:17px;font-weight:bold;color:rgb(238,142,22)"><span style="font-size:16px"><strong>Josh Stompro</strong></span></div>
<div style="font-family:"arial","helvetica",sans-serif;font-size:12px;line-height:14px;font-weight:normal;color:rgb(0,0,0);margin-bottom:10px"><span style="font-size:13px"><strong><em>IT Director</em><br>
<a href="mailto:stomproj@gsuite.larl.org" style="text-decoration:none;color:rgb(27,70,153)" target="_blank">stomproj@gsuite.larl.org</a></strong><br>
<strong>218-233-3757 ext. 139</strong> </span><span style="font-size:13px"><span style="color:rgb(1,186,239)">| </span><strong>Mobile: 218-790-2110</strong></span><br>
<br>
<span style="font-size:13px"><strong><span style="color:rgb(27,70,152)">Lake Agassiz Regional Library | </span></strong></span><span style="font-size:13px"><strong><a href="http://www.larl.org" style="text-decoration:none;color:rgb(27,70,153)" target="_blank">www.larl.org</a></strong><br>
118 5th ST S<br>Moorhead MN 56560<br>
<span style="color:rgb(1,186,239)"><em><strong>Celebrating 60 Years of Service in 2021!</strong></em></span></span></div>
</td></tr></tbody></table>
</div></div></div></div>
_______________________________________________<br>
Eg-newdevs mailing list<br>
<a href="mailto:Eg-newdevs@list.evergreen-ils.org" target="_blank">Eg-newdevs@list.evergreen-ils.org</a><br>
<a href="http://list.evergreen-ils.org/cgi-bin/mailman/listinfo/eg-newdevs" rel="noreferrer" target="_blank">http://list.evergreen-ils.org/cgi-bin/mailman/listinfo/eg-newdevs</a><br>
</blockquote></div>