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

cancel
Showing results for 
Search instead for 
Did you mean: 

Date Compare custom object 5.5 SP2

ChiragShah
Contributor II

Hi All,

 

We have a custom object in Archer 5.4 which compares start and end date. If the end date selected by the user is less than (before) start date it will give warning message and not allow to save or apply the record.

 

Post upgrade to Archer 5.5 SP2 the functionality is not working.

 

It will restrict the user form save or apply the record is end date if less than start sate but will not give warning message (pop up box).

Have attached the querry used in 5.4 below. Any help will be highly appreciated.

 

Regards,

Chirag.

 

<script type="text/javascript">   
var startDate = 4507, startDateValue;   
var endDate = 14721, endDateValue;   
var messageBoxText = "Please select a valid end date. End date cannot be before Start date";   
var messageBoxTitle = 'Warning';   
var daysToCompare = -1;
Sys.Application.add_load(function() {   
   // Hijack Save/Apply Buttons   
   $('#master_btnSave').attr('href',"#").removeAttr("onclick").unbind("click").click(function(){ DateCheck

('save');return false;});   
   $('#master_btnSave > div > div > img').removeAttr('onclick').unbind("click");   
   $('#master_btnApply').attr('href',"#").removeAttr('onclick').unbind("click").click(function(){ DateCheck

('apply');return false;});   
   $('#master_btnApply > div > div > img').removeAttr('onclick').unbind("click");   
});
function DateCheck(type) {   
   //Get Date Values   
startDateValue = new Date(String(ArcherTech.UI.GenericContent.GetInstance().getFieldValue(startDate, false)));
endDateValue = new Date(String(ArcherTech.UI.GenericContent.GetInstance().getFieldValue(endDate, false)));   
   if(startDateValue && endDateValue) {   
    if(daydiff(parseDate(startDateValue), parseDate(endDateValue)) <= daysToCompare) {   
      WarningAlert(messageBoxText,'',messageBoxTitle);   
    } else {   
      SaveApply(type)   
    }   
   } else {   
    SaveApply(type)   
   }   

function SaveApply(type) {   
   if (type == 'save') {   
    ShowAnimationAndPostback('master$btnSave');   
   } else if (type == 'apply') {   
    ShowAnimationAndPostback('master$btnApply');   
   }   

function parseDate(str) {   
   str = str.getMonth()+1 + '/' + str.getDate() + '/' + str.getYear();   
   var mdy = str.split('/')   
   return new Date(mdy[2], mdy[0]-1, mdy[1]);   

function daydiff(first, second) {   
   return (second-first)/(1000*60*60*24)   
}
</script>

57 REPLIES 57

David Petty wrote:

 

Thanks Sam, the WarningAlert is an Archer function to display a dialog box; fitting with Archer UI to the user. Though looking at that function call, it seems that I've got the parameters wrong for the call. Tiara hasn't reported any errors being reported in the browsers console since she first reported about an error in radwindowscript.js.  Since then we've changed the way the script is checking the dates and it's not getting to that line.

 

Tiara replace (line 27), WarningAlert(messageBoxText,'',messageBoxTitle); with WarningAlert(messageBoxText,messageBoxTitle);

Still a no go. here is what the console provides:

'weaknessStartDate' is undefined on this line

weaknessStartDateValue = new Date(String(ArcherTech.UI.GenericContent.GetInstance().getFieldValue(weaknessStartDate, false)));

workspace.aspx says object doesn't support this property or method

 

 

 

 

Ah were getting somewhere now

 

During name changes for the variable something got messed up with weaknessStartDate variable.  On line 2 change var weaknessWeaknessStartDate = 22883, weaknessWeaknessStartDateValue;  to var weaknessStartDate = 22883, weaknessStartDateValue;   You had weakeness listed twice in the variable name

 Advisory Consultant

Ok something as simple as that and I thought I changed it. IT WORKED YAY!!!! Thank you so much.

My pleasure Tiara.

 

The simple things in JavaScript that drive one insane

 Advisory Consultant

Ok this time its a question. Can I have multiple custom objects in one application that validate dates? This date has a DDE on it so its not required until the record status says complete...so it doesn't need to validate the date until the user changes the status to completed.

It could be added the current custom object, but you'd have to make changes to the DateCheck function in order for you to do this by adding extra checks against the status field along with adding additional variables for the new date field and for the status values list.

 Advisory Consultant

Hey David,

 

I'm at it again just in 6.2.3 and the alert box appears but it doesn't allow us to save.  I think it is because the javascript is trying to find the apply button. can you please help with this. I tried to use the same javascript and make changes to the saveapply function. Please help. Thanks

Hi David, 

                 i am trying to get a selected value list value in Archer v6.2 and tried the span , id and Name and found no luck all it comes is empty or undefined any suggestions would be of great help.

$('input[id*="f29963c"').text()


$('#master_DefaultContent_rts_s2621_f29963c').val()


$('#master_DefaultContent_rts_s2621_f29963c').find('option:selected').text();

Are you making the call inside of Sys.Application.add_load(function() { $('input[id*="f29963c_shf"').val()}); ?

 Advisory Consultant

Hi David ,

           thanks a lot for the reply , i get text in the form of JSON ,but not the value alone which is  text : working fine

is there any already method which returns only text ?

             {"enabled":true,"value":"14004:0","text":"working fine","selected":true,"active":true}
Submit to Finding Owner