Important Update: Community URLs redirect issues are partially resolved. Learn More. .

cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to clone/hijack a dropdown item using Custom Objects

cletusj
Contributor
Screen Shot 2022-08-19 at 12.50.47 PM.png
 
Hi All,
 
The code below should validate a date field when "Save", "Save and Close" and "Continue to Finding" are selected from the Actions dropdown item.
 
The only part not working is "Continue to Finding".  Can someone look at
the code and let me know what I'm missing.
 
-----------------------------------------------

 

<script type="text/javascript">

const dateIdentifiedId = 19854;
const firstPublishedId = 2275;

Sys.Application.add_load(function () {

// Clone the "Save" button.
$('#master_btnApply1').clone().attr('id', 'master_customBtnSave').insertBefore('#master_btnApply1');
$('#master_btnApply1').hide();
$('#master_customBtnSave').unbind('click').prop("onclick", null).click(function () { validateDate("save"); return false; });

// Clone the "Save and Close" button.
$('#master_btnSave1').clone().attr('id', 'master_customBtnSaveAndClose').insertBefore('#master_btnSave1');
$('#master_btnSave1').hide();
$('#master_customBtnSaveAndClose').unbind('click').prop("onclick", null).click(function () { validateDate("save_close"); return false; });

// Clone the "Continue to Finding" item
// $("div:contains('Continue to Finding')").clone().attr('id', 'master_customContinueItem').insertBefore("div:contains('Continue to Finding')");
// $("div:contains('Continue to Finding')").hide();
// $('#master_customContinueItem').unbind('click').prop("onclick", null).click(function () { validateDate("continue"); return false; });

// Clone the "Continue to Finding" item
$('#master_4958:CUST').clone().attr('id', 'master_customContinueItem').insertBefore('#master_4958:CUST');
$('#master_4958:CUST').hide();
$('#master_customContinueItem').unbind('click').prop("onclick", null).click(function () { validateDate("continue"); return false; });
});

function validateDate(action) {
var dateIdentifiedValue = $CM.getFieldValue(dateIdentifiedId); //CM = Client Manager
var firstPublishedValue = $CM.getFieldById(firstPublishedId).value;

//alert(dateIdentifiedValue);
//alert(firstPublishedValue);

if (dateIdentifiedValue == null || dateIdentifiedValue == "") {
alert("Date Identified cannot be empty");
}
else {

if (dateIdentifiedValue.getTime() <= firstPublishedValue.getTime()) {

if (action == "save") {
//Perform actual "Save" function
$("#master_btnApply1").click();
} else if (action == "save_close") {
//Perform "Save and Close" function
$("#master_btnSave1").click();
}
else {
//Perform "Continue to Finding" function
// $("div:contains('Continue to Finding')").click();
$("#master_4958:CUST").click();
}
}
else {
alert("Date Identified cannot be greater than First Published date");
}
}
}
</script>

 

0 REPLIES 0