Precisely Enterworks

 View Only
  • 1.  Date - Date Type Attribute Manipulation

    Posted 01-19-2023 09:41
    Hello! 

    I'm looking to see if anyone has experience with leveraging the ability to manipulate 'DATE' data type attributes. My goal is to have attribute X = a specific date and then with some process (haven't managed to determine the best course of action) add an x amount of days which would then populate as this future date on attribute Y. 

    So far, I've tried various VTL formulas, Change Notification - Update process, Change Notification - Transformation process but nothing viable as a result.

    Any suggestions or advice would be greatly appreciated!

    ------------------------------
    Brittany Adams | Data Management Steward
    DAS Companies
    ------------------------------


  • 2.  RE: Date - Date Type Attribute Manipulation

    Posted 01-26-2023 22:17
    Hi Brittany,
    Please check if this helps: 
    (AssignFutureDateToAttribute is an attribute used to control which records need such assignment and which do not)

    #if("${this}" == '' && "${AssignFutureDateToAttribute}" == 'YES') --------------(if NO, then no action required)
    #set($str="")
    #set($dt=$str.getClass().forName("java.time.LocalDateTime"))
    #set($dtf=$str.getClass().forName("java.time.format.DateTimeFormatter"))
    $dt.now().plusDays(90).format($dtf.ofPattern("MM/dd/yyyy"))
    #else
    ${this}
    #end

    Vijay Zarapala,
    MDM/PIM Expert
    HD Supply (Home Depot)
    6784512789

    ------------------------------
    Vijay Zarapala | Sr Developer
    HD Supply | 6788245789
    ------------------------------



  • 3.  RE: Date - Date Type Attribute Manipulation

    Posted 02-01-2023 07:57
    Hello Vijay,

    Thank you, for your suggestion! I will test this out.

    ------------------------------
    Brittany Adams | Data Management Steward
    DAS Companies
    ------------------------------



  • 4.  RE: Date - Date Type Attribute Manipulation

    Posted 02-02-2023 15:19
    I agree with Vijay. VTL is most likely the best way to go here.

    Good luck!

    ------------------------------
    Jon Varo | Manager - Master Data and PIM Teams
    Fender Musical Instruments Corporation | (480) 845-5823
    ------------------------------



  • 5.  RE: Date - Date Type Attribute Manipulation

    Posted 02-07-2023 10:28
    Hello Vijay and Jon,

    This was a great exercise as I continue to develop my VTL skills (slowly, but surely). I was able to get this to work for us, and I look forward to being able to implement it for other potential processes in the future, as well.  

    Thank you, both! 


    ------------------------------
    Brittany Adams | Data Management Steward
    DAS Companies
    ------------------------------



  • 6.  RE: Date - Date Type Attribute Manipulation

    Posted 02-07-2023 15:20

    You are welcome ��






  • 7.  RE: Date - Date Type Attribute Manipulation

    Posted 09-06-2023 14:54

    Hello Vijay, 

    I am looking to update the above VTL code in our system. Instead of adding days to the current date, we would like to add the same amount of days to various dates that are input into the system. Essentially we would like to start a product life cycle tracker and populate dates in fields to show the various milestones we'd like to hit (i.e. every 30 days, the date for the next milestone is auto-populated). Do you have any suggestions on how to complete this?

    Currently, I've tested the code below that parses the date but I can only get it to work when typing in '2023-05-10T00:00:00.00' as a text field in 'MANUALDATEADDED'. While this works it is not very user friendly! 

    #set($str="")
    #set($dt=$str.getClass().forName("java.time.LocalDateTime"))
    #set($dtf=$str.getClass().forName("java.time.format.DateTimeFormatter"))
    $dt.parse("${Item_Staging.MANUALDATEADDED}").plusDays(30).format($dtf.ofPattern("MM/dd/yyyy"))
    $dt
    #end



    ------------------------------
    Brittany Adams
    DAS Companies
    ------------------------------



  • 8.  RE: Date - Date Type Attribute Manipulation

    Employee
    Posted 09-07-2023 02:11

    Brittany,

    VTL comes with some Classes including DateTool, which includes methods to convert a String to a date (using a specified format).  The set of classes can be found at the following URL:  https://velocity.apache.org/tools/1.4/javadoc/org/apache/velocity/tools/generic/package-summary.html

    Using VTL to calculate new dates is effective when there is a data change that can drive the VTL being executed.  Change Notification (and Transformation) can also be used and the calculations and formatting performed in SQL.  With a CN_Registry rule, the CN_External_Attributes_SQL attribute can be used to define a SQL SELECT query (or a call to a stored procedure) that calculates a new value and then the Update configuration set the desired attributes to the calculated values.  To avoid always executing the SQL for each event, a CN_Transformation_Registry rule can be defined that has the CN_Target_SQL defined that invokes the SELECT query or stored procedure that returns columns for each calculated attribute in the query or stored procedure results.  There are numerous EnterWorks Tech Talk recordings on the Precisely University covering all aspects of Change Notification.

    If the calculated attributes are time driven, meaning each day new values may need to be calculated for some records, then the simplest way to accomplish this is to create a View (SQL) Scheduled Export that calculates the new values for all records requiring them and generating an update file that is then fed to a Scheduled Import to update those records in the same repository.

    If you are looking to use these special calculations to drive actual Scheduled jobs, you can use the Export/Import technique to calculate the next appropriate day and time for a job to run (assuming that built-in schedule options cannot produce the desired result).  The EnterWorks Tech Talk ETT-145 - How to Set up Complex Schedules for Scheduled Jobs shows how to accomplish this.



    ------------------------------
    Brian Zupke
    Precisely Software Inc.
    ------------------------------



  • 9.  RE: Date - Date Type Attribute Manipulation

    Posted 09-07-2023 10:03

    Hello Brian, 

    Thank you for your response. This feedback is very helpful. I started working on a Change Notification update using the CN_External_Attributes_SQL field. I think this option will work for what we are trying to implement. I am able to get the new date field updated using this code

     SELECT DATEADD(day, 7, '2023-09-01') AS DaysAdded from Item_Staging 

    However, I don't want to hardcode the date in, I want to pull the date from another attribute that the user would input a date into (attribute name 'Manual Date Added') for example. Do you have any suggestions on how I could manipulate the code to pull in that date from the field and not a hardcoded date?

    Thank you, 

    Brittany



    ------------------------------
    Brittany Adams
    DAS Companies
    ------------------------------



  • 10.  RE: Date - Date Type Attribute Manipulation

    Posted 09-07-2023 13:35

    I was able to figure this out and realized that I needed to format it as such -  '||attributename||'. 



    ------------------------------
    Brittany Adams
    DAS Companies
    ------------------------------