Inserting today as yyyy-mm-dd into XML?

Last post 01-08-2016, 7:01 PM by Gabriel Rosenkoetter. 2 replies.
Sort Posts: Previous Next
  • Inserting today as yyyy-mm-dd into XML?
    Posted: 11-12-2015, 11:12 AM

    sp_copycreation.xml takes in <timeValue> a date in the form of yyyy-mm-dd. I tried inserting the system variable for the job start timestamp, but that didn't parse correctly, presumably at least partly because it had the time as well as the date. Then I added an input field to the workflow in date format, which I then inserted into the XML -- but apparently that, too, was in the wrong format.

    Is there a canonical/best practice method for generating today's date as yyyy-mm-dd for use in an XML string in a workflow?

    Learning something every day,

    Nick

    (Simpana 10.10, since I'm sure everything's better in N+1)

  • Re: Inserting today as yyyy-mm-dd into XML?
    Posted: 11-20-2015, 4:36 AM

    Hi,

    The date format is yyyy-mm-dd.

     

    To set timeValue you need to specify the following fields also.

     <createNewDDBeveryXmonths>1</createNewDDBeveryXmonths>

    <months>2</months>

     

    Example:

    <App_CreateStoragePolicyCopyReq>

    <copyName>cmd_test</copyName>

    <storagePolicyCopyInfo>

    <copyType/>

    <active>1</active>

    <isSnapCopy>0</isSnapCopy>

    <isMirrorCopy>0</isMirrorCopy>

    <deferAuxiliaryCopyDays>0</deferAuxiliaryCopyDays>

    <hardWareCompression>0</hardWareCompression>

    <provisioningPolicyName/>

    <vFilerName/>

    <throttleNetworkBandWidthMBHR/>

    <StoragePolicyCopy>

    <storagePolicyName>test</storagePolicyName>

    </StoragePolicyCopy>

    <copyFlags>

    <multiplexSourceStreams>2</multiplexSourceStreams>

    <combineStreams>2</combineStreams>

    <switchIfOffline>2</switchIfOffline>

    <switchIfBusy>2</switchIfBusy>

    <demultiplexOnCopy>2</demultiplexOnCopy>

    <markMediaToBeErasedAfterRecycling>2</markMediaToBeErasedAfterRecycling>

    <archiveCheckAll>2</archiveCheckAll>

    <archiveCheckFull>2</archiveCheckFull>

    <archiveCheckBitmap>2</archiveCheckBitmap>

    <roundRobbinDataPath>2</roundRobbinDataPath>

    <inlineAuxCopy>2</inlineAuxCopy>

    <enableParallelCopy>2</enableParallelCopy>

    <lastFull>2</lastFull>

    <lastFullWait>2</lastFullWait>

    <autoAddDataPaths>2</autoAddDataPaths>

    <noInlineCopyToSameLibrary>2</noInlineCopyToSameLibrary>

    <noAuxCopyToSameLibrary>2</noAuxCopyToSameLibrary>

    <storeKeyOnMedia>2</storeKeyOnMedia>

    <sourceCopyForSnapToTape>2</sourceCopyForSnapToTape>

    <siloCopy>2</siloCopy>

    <auxCopyReencryptData>2</auxCopyReencryptData>

    <wormCopy>2</wormCopy>

    <enableMediaRefresh>2</enableMediaRefresh>

    <useHardwareSnapshot>2</useHardwareSnapshot>

    <enableLanFreeReservationOnly>2</enableLanFreeReservationOnly>

    <useStreamsOverMultiplexing>2</useStreamsOverMultiplexing>

    <useDirectAttachedNASDrivePool>2</useDirectAttachedNASDrivePool>

    <deleteCopyAfterJobsAreDeleted>2</deleteCopyAfterJobsAreDeleted>

    </copyFlags>

    <extendedFlags>

    <dynamicStreamAllocation>2</dynamicStreamAllocation>

    <secondarySiloCopy>2</secondarySiloCopy>

    </extendedFlags>

    <library>

    <libraryName>test1</libraryName>

    </library>

    <mediaAgent>

    <mediaAgentName>tom</mediaAgentName>

    </mediaAgent>

    <drivePool>

    <drivePoolName/>

    <libraryName/>

    </drivePool>

    <spareMediaGroup>

    <spareMediaGroupName/>

    <libraryName/>

    </spareMediaGroup>

    <dataPathConfiguration>

    <resourcesOfflineWaitTimeInHoursMinutes>

    <hours/>

    <minutes/>

    </resourcesOfflineWaitTimeInHoursMinutes>

    <resourcesBusyWaitTimeInHoursMinutes>

    <hours/>

    <minutes/>

    </resourcesBusyWaitTimeInHoursMinutes>

    </dataPathConfiguration>

    <dataVerification>

    <allJobs>2</allJobs>

    <allFullJobs>2</allFullJobs>

    <verificationExpiresAfterMonths/>

    <jobsOnOrAfterDate>

    <timeValue/>

    </jobsOnOrAfterDate>

    </dataVerification>

    <dataEncryption>

    <encryptData>2</encryptData>

    <encryptionType/>

    <encryptionKeyLength/>

    <reEncryptDataUsingCipher>2</reEncryptDataUsingCipher>

    <viaMediaPassword>2</viaMediaPassword>

    </dataEncryption>

    <retentionRules>

    <retainBackupDataForDays>-1</retainBackupDataForDays>

    <retainBackupDataForCycles>-1</retainBackupDataForCycles>

    <retainArchiverDataForDays>-1</retainArchiverDataForDays>

    <jobs/>

    <retentionFlags>

    <extendedRetentionFirst>2</extendedRetentionFirst>

    <enableDataAging>2</enableDataAging>

    <enableManagedDiskSpace>2</enableManagedDiskSpace>

    <selectJobsFromPreviousTier>2</selectJobsFromPreviousTier>

    <retainFullAndLastDifferential>2</retainFullAndLastDifferential>

    <jobBasedRetention>2</jobBasedRetention>

    <grcRemoteCopy>2</grcRemoteCopy>

    <flagsMask>2</flagsMask>

    </retentionFlags>

    <extendedRetentionRuleOne>

    <endDays>90</endDays>

    <graceDays>0</graceDays>

    <isEnabled>2</isEnabled>

    <rule>EXTENDED_ALLFULL</rule>

    </extendedRetentionRuleOne>

    <extendedRetentionRuleTwo>

    <endDays>365</endDays>

    <graceDays>1</graceDays>

    <isEnabled>2</isEnabled>

    <rule>EXTENDED_WEEK</rule>

    </extendedRetentionRuleTwo>

    <extendedRetentionRuleThree>

    <endDays>1825</endDays>

    <graceDays>2</graceDays>

    <isEnabled>2</isEnabled>

    <rule>EXTENDED_MONTH</rule>

    </extendedRetentionRuleThree>

    <financialCalendarXML>

    <calendarId>1</calendarId>

    <monthStartsOn>1</monthStartsOn>

    <startingMonthOfYear>JANUARY</startingMonthOfYear>

    <weekStartsOn>FRIDAY</weekStartsOn>

    </financialCalendarXML>

    </retentionRules>

    <mediaProperties>

    <multiplexingFactor>0</multiplexingFactor>

    <numberOfStreamsToCombine/>

    <mediaRefreshProperties>

    <percentage>51</percentage>

    <refreshFlags>

    <enableMediaRetirementThreshold>2</enableMediaRetirementThreshold>

    </refreshFlags>

    <monthsAfterMediaWritten>

    <months>12</months>

    </monthsAfterMediaWritten>

    <monthsBeforeMediaAged>

    <months>3</months>

    </monthsBeforeMediaAged>

    </mediaRefreshProperties>

    </mediaProperties>

    <selectiveCopyRules>

    <selectiveRule/>

    <dayStartsAt/>

    <weekDayStartsOn/>

    <monthStartsOn/>

    <startingMonthOfYear/>

    <everyXCycles/>

    <everyXHours/>

    <everyXDays/>

    <everyXWeeks/>

    <everyXMonths/>

    <firstFullBackup>2</firstFullBackup>

    <selectMostRecentJob>2</selectMostRecentJob>

    <doNotAutomaticallySelectJobs>2</doNotAutomaticallySelectJobs>

    <moveJobSelectionStartTime/>

    </selectiveCopyRules>

    <auxCopyFallenBehind>

    <enableAuxCopyFallenBehindAlert>2</enableAuxCopyFallenBehindAlert>

    <enableToBeCopiedDataTB>2</enableToBeCopiedDataTB>

    <toBeCopiedDataTB/>

    <enableDaysOldJobs>2</enableDaysOldJobs>

    <daysOldJobs/>

    <enableHoursToCopyData>2</enableHoursToCopyData>

    <hoursToCopyData/>

    </auxCopyFallenBehind>

    <sourceCopy>

    <copyName/>

    <storagePolicyName/>

    </sourceCopy>

    <DDBPartitionInfo>

    <maInfoList>

    <mediaAgent>

    <mediaAgentName>tom</mediaAgentName>

    </mediaAgent>

    <subStoreList>

    <diskFreeThresholdMB>5120</diskFreeThresholdMB>

    <diskFreeWarningThreshholdMB>10240</diskFreeWarningThreshholdMB>

    <accessPath>

    <path>c:\cmdDDB\3</path>

    </accessPath>

    </subStoreList>

    </maInfoList>

    <sidbStoreInfo>

    <operation>1</operation>

    <copyName/>

    <enableNumberOfSilosToBeKeptInCache>2</enableNumberOfSilosToBeKeptInCache>

    <numberOfSilosToBeKeptInCache>1</numberOfSilosToBeKeptInCache>

    <sidbStoreFlags>

    <enableSoftwareCompression>2</enableSoftwareCompression>

    </sidbStoreFlags>

    <mediaAgentForSiloRestores>

    <mediaAgentName/>

    </mediaAgentForSiloRestores>

    <destinationClientForSiloRestores>

    <mediaAgentName/>

    </destinationClientForSiloRestores>

    </sidbStoreInfo>

    </DDBPartitionInfo>

    <dedupeFlags>

    <useDDBPrimingOption>2</useDDBPrimingOption>

    <optimizeHighLatencyNetwork>2</optimizeHighLatencyNetwork>

    <minimumPartitionsToBeAvailableForJobsToRun>2</minimumPartitionsToBeAvailableForJobsToRun>

    <enableSIDBArchive>2</enableSIDBArchive>

    <enableDeduplication>1</enableDeduplication>

    <temporarilyDisableDeduplication>2</temporarilyDisableDeduplication>

    <enableClientSideDedup>2</enableClientSideDedup>

    <backupSiloEnabled>2</backupSiloEnabled>

    <isSilosToBeKeptInCache>2</isSilosToBeKeptInCache>

    <enableDASHFull>2</enableDASHFull>

    <enableSiloDiskSpaceManagement>2</enableSiloDiskSpaceManagement>

    <pauseAndRecoverCurrentDDB>2</pauseAndRecoverCurrentDDB>

    <automaticallyPauseAndRecoverDDB>2</automaticallyPauseAndRecoverDDB>

    <useGlobalDedupStore>2</useGlobalDedupStore>

    <hostGlobalDedupStore>2</hostGlobalDedupStore>

    <markClientCacheDbDirty>2</markClientCacheDbDirty>

    <enableSourceSideDiskCache>2</enableSourceSideDiskCache>

    </dedupeFlags>

    <createNewDDBOptions>

    <createNewDDBeveryXdays>2</createNewDDBeveryXdays>

    <days>30</days>

    <createNewDDBeveryXtb>2</createNewDDBeveryXtb>

    <tb>100</tb>

    <createNewDDBeveryXmonths>1</createNewDDBeveryXmonths>

    <months>2</months>

    <startingFromDate>

    <timeValue>2015-11-25</timeValue>

    </startingFromDate>

    </createNewDDBOptions>

    <associations>

    <client>

    <clientName/>

    </client>

    <appType>

    <appName/>

    <clientName/>

    </appType>

    <instance>

    <instanceName/>

    <clientName/>

    </instance>

    <backupSet>

    <backupsetName/>

    <clientName/>

    </backupSet>

    <subClient>

    <subclientName/>

    <instanceName/>

    <backupsetName/>

    <clientName/>

    </subClient>

    </associations>

    <resourcePoolsList>

    <operation>1</operation>

    <resourcePoolName/>

    </resourcePoolsList>

    </storagePolicyCopyInfo>

    <useGlobalPolicy>

    <storagePolicyName/>

    </useGlobalPolicy>

    </App_CreateStoragePolicyCopyReq>

     

  • Re: Inserting today as yyyy-mm-dd into XML?
    Posted: 01-08-2016, 7:01 PM

    There are probably myriad ways to get where you want to go here.

    It sounds like what you want isn't having the user enter a date (although I'll get to that in a minute), but just defaulting to "today" where "the day the workflow started" is probably close enough.

    xpath:{/workflow/system/startTime} is a Java variable of type java.util.Date. I think what you ended up with (presuming you passed this to a LogEvent activity or a logger.info() call) was something of the form YYYY-MM-DD-HHHH, where the hours aren't actually time, but offset from UTC (see https://en.wikipedia.org/wiki/ISO_8601 - this is kinda sorta one of those formats). You do want an ISO 8601 format date, but without the time offset. The way I'd get that in a Workflow is in a Java Script activity, and the way I'd get that in Java is through the java.text.SimpleDateFormat class. On the Script tab of the Script activity, that'd look like this:

    import java.text.SimpleDateFormat;
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    return dateFormat.format(xpath:{/workflow/system/startTime});

    For various reasons, what you get out of the date selection dropdown isn't a java.util.Date object. I'm not a CV developer, so I'm not sure whether what you get out of this is affected by the locale of the system where your Workflow Engine or CommCell is running, but what I get there is a java.util.GregorianCalendar object. Even if your locale uses a different calendar format, it should still inherit the getTime() method from java.util.Calendar, which produces a Date object, so we can more or less do the same thing, like this:

    import java.text.SimpleDateFormat;
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    return dateFormat.format(xpath:{/workflow/inputs/date}.getTime());

    Yes, the naming of getTime() is kind of strange when what you want is just a date, but in this case a specific time necessarily also includes the date: so you want that value, you just want to display it less specifically.

    I've attached a Workflow with both examples. (You may need to rename it from .txt to .xml: the form doesn't permit uploading files with a .xml extension.) 

    Attachment: DEMO - munge date.txt
The content of the forums, threads and posts reflects the thoughts and opinions of each author, and does not represent the thoughts, opinions, plans or strategies of Commvault Systems, Inc. ("Commvault") and Commvault undertakes no obligation to update, correct or modify any statements made in this forum. Any and all third party links, statements, comments, or feedback posted to, or otherwise provided by this forum, thread or post are not affiliated with, nor endorsed by, Commvault.
Commvault, Commvault and logo, the “CV” logo, Commvault Systems, Solving Forward, SIM, Singular Information Management, Simpana, Commvault Galaxy, Unified Data Management, QiNetix, Quick Recovery, QR, CommNet, GridStor, Vault Tracker, InnerVault, QuickSnap, QSnap, Recovery Director, CommServe, CommCell, SnapProtect, ROMS, and CommValue, are trademarks or registered trademarks of Commvault Systems, Inc. All other third party brands, products, service names, trademarks, or registered service marks are the property of and used to identify the products or services of their respective owners. All specifications are subject to change without notice.
Close
Copyright © 2019 Commvault | All Rights Reserved. | Legal | Privacy Policy