webdrawer change DateCreated format in detailsview page

How change the "DateCreated" field format in detailsview page. Currently it shows like "Thursday, 21 November 2024 at 5:05 PM", but i want to show like "dd/MM/yyyy" only. 

Thanks,

Sarath.

  • 0  

    Hi Sarath,

    Looks like the date format is fixed (Checked in 23.4)

    Doesn't look like the date format setting in the user options applies to the details pane Disappointed

    Recommend logging an enhancement request or posting to the Idea Exchange to get it on OT's radar.

    -Scotty

  • Verified Answer

    +1 in reply to   

    Thanks scott for your response. This setting is already did. My question is on webdrawer detailsview page. 

    thanks,

    Sarath.

  • Verified Answer

    +1   in reply to 

    Hi Sarath,

    Apologies - I missed that as part

    Yep you can do it my modifying the underlying Razor page (Below is from my 23.4 demo machine)

    Open up the file ..\Content Manager\WebDrawer\Views\Shared\propertyRow.cshtml in your favourite notepad editor

    Scroll down to the below block of code (around line 40 something)

    else if (searchClause != null)
    {
    	<a href="~/@Model.TrimObject.TrimType?q=@searchClause">
    		<span class="prop-val">@valString</span>
    	</a>                
    }

    and change it to

    else if (searchClause != null)
    {
    	if (Model.pfdef.PFFormat == PropertyOrFieldFormat.Datetime)
    	{
    		// Remove the word "at" from the string
    		string cleanedValString = valString.Replace(" at ", " ");
    	
    		DateTime parsedDate;
    		if (DateTime.TryParse(cleanedValString, out parsedDate))
    		{
    			<a href="~/@Model.TrimObject.TrimType?q=@searchClause">
    				<span class="prop-val">@parsedDate.ToString("dd/MM/yyyy")</span>
    			</a>
    		}
    		else
    		{
    			<a href="~/@Model.TrimObject.TrimType?q=@searchClause">
    				<span class="prop-val">Invalid Date</span>
    			</a>
    		}    
    	}
    	else
    	{
    		<a href="~/@Model.TrimObject.TrimType?q=@searchClause">
    			<span class="prop-val">@valString</span>
    		</a>                
    	}							
    }

    This should then update any 'clickable' DateValues (those bound to searches) showing in the details pane in WebDrawer from

    to

    You can update the bottom 'else' clause to handle 'Non Clickable' dates as well (Eg. Date Due for Destruction in the Archiving slider)

    else
    {
    	<span class="prop-val">@valString</span>              
    }

    becomes

    else
    {
    	if (Model.pfdef.PFFormat == PropertyOrFieldFormat.Datetime)
    	{
    		// Remove the word "at" from the string
    		string cleanedValString = valString.Replace(" at ", " ");
    	
    		DateTime parsedDate;
    		if (DateTime.TryParse(cleanedValString, out parsedDate))
    		{
    			<span class="prop-val">@parsedDate.ToString("dd/MM/yyyy")</span>
    		}
    		else
    		{
    			<span class="prop-val">Invalid Date</span>
    		}    
    	}
    	else
    	{
    		 <span class="prop-val">@valString</span>              
    	}	            
    }

    which changes

    to

    Haven't thoroughly checked with all properties so your mileage may vary slightly.

    -Scotty

  • 0 in reply to   

    Thanks scotty for the solution. now it works.

    Thanks,

    Sarath.