diff --git a/src/registrar/assets/js/get-gov-admin.js b/src/registrar/assets/js/get-gov-admin.js index 1f5ab6734..e2fb8e953 100644 --- a/src/registrar/assets/js/get-gov-admin.js +++ b/src/registrar/assets/js/get-gov-admin.js @@ -810,8 +810,8 @@ function initializeWidgetOnList(list, parentId) { }else if (selectedText === "Non-Federal Agency" && organizationType.value === "federal") { organizationType.value = ""; } - - // There isn't a senior official associated with null records and non federal agencies + + // There isn't a federal senior official associated with null records and non federal agencies if (!selectedText || selectedText === "Non-Federal Agency") { return; } @@ -825,11 +825,16 @@ function initializeWidgetOnList(list, parentId) { let seniorOfficialApi = document.querySelector("#senior_official_from_agency_json_url").value; fetch(`${seniorOfficialApi}?agency_name=${selectedText}`) - .then(response => response.json()) - .then(data => { + .then(response => { + const statusCode = response.status; + return response.json().then(data => ({ statusCode, data })); + }) + .then(({ statusCode, data }) => { if (data.error) { - // Clear the field if the SO doesn't exist - $seniorOfficial.val("").trigger("change"); + // Clear the field if the SO doesn't exist. + if (statusCode === 404) { + $seniorOfficial.val("").trigger("change"); + } console.error("Error in AJAX call: " + data.error); return; } diff --git a/src/registrar/models/portfolio.py b/src/registrar/models/portfolio.py index e705aaa83..484c45e8c 100644 --- a/src/registrar/models/portfolio.py +++ b/src/registrar/models/portfolio.py @@ -114,7 +114,7 @@ class Portfolio(TimeStampedModel): def save(self, *args, **kwargs): """Save override for custom properties""" - # We can't have urbanization if the state isn't puerto rico + # The urbanization field is only intended for the state_territory puerto rico if self.state_territory != self.StateTerritoryChoices.PUERTO_RICO and self.urbanization: self.urbanization = None