How to add Current Date in Catalog item App Spec

I want to use current time in catalog item app spec… is there any way we can use the date function in App spec?

for example:

You could possibly utilize the Morpheus variable(s) for dateCreated. Something like <%=server.dateCreated%> and then if it needs to be date or time only use groovy logic to parse that.

https://docs.morpheusdata.com/en/latest/troubleshooting/Variables_Examples.html

isn’t the <%=server.dateCreated%> will be used after the server creaeted rite? when i use that in the Catalog item app spec i am getting name not found error

Are you putting it in quotes? Name not found sounds like invalid YAML at that point

current_time: ‘<%= server.dateCreated %>’ → i gave like this and getting the below error in logs

2023-05-18_17:53:57.63912 ‘’[2023-05-18 17:54:07,425] [http-nio-127.0.0.1-8080-exec-53] INFO c.m.i.ScribeService - scribe - provision order app template: com.morpheus.CatalogItem : (unsaved)
2023-05-18_17:54:07.42583 ‘’[2023-05-18 17:54:07,620] [http-nio-127.0.0.1-8080-exec-53] WARN c.m.MorpheusUtils - buildSpecVariableScript error: groovy.lang.MissingPropertyException: No such property: server for class: SimpleTemplateScript539528
2023-05-18_17:54:07.62075 'groovy.lang.MissingPropertyException: No such property: server for class: SimpleTemplateScript539528
2023-05-18_17:54:07.62075 at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:65)
2023-05-18_17:54:07.62076 at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:51)
2023-05-18_17:54:07.62077 at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:341)
2023-05-18_17:54:07.62079 at SimpleTemplateScript539528.run(SimpleTemplateScript539528.groovy:1)
2023-05-18_17:54:07.62079 at groovy.text.SimpleTemplateEngine$SimpleTemplate$1.writeTo(SimpleTemplateEngine.java:177)
2023-05-18_17:54:07.62080 at groovy.text.SimpleTemplateEngine$SimpleTemplate$1.toString(SimpleTemplateEngine.java:189)
2023-05-18_17:54:07.62080 at jdk.internal.reflect.GeneratedMethodAccessor2277.invoke(Unknown Source)
2023-05-18_17:54:07.62080 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2023-05-18_17:54:07.62083 at java.base/java.lang.reflect.Method.invoke(Unknown Source)
2023-05-18_17:54:07.62084 at org.codehaus.groovy.runtime.callsite.PlainObjectMetaMethodSite.doInvoke(PlainObjectMetaMethodSite.java:43)
2023-05-18_17:54:07.62085 at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:214)
2023-05-18_17:54:07.62086 at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
2023-05-18_17:54:07.62087 at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:130)
2023-05-18_17:54:07.62088 at com.morpheus.MorpheusUtils.buildConfigVariableScript(MorpheusUtils.groovy:917)
2023-05-18_17:54:07.62089 at com.morpheus.MorpheusUtils$buildConfigVariableScript$69.call(Unknown Source)
2023-05-18_17:54:07.62090 at com.morpheus.integration.ScribeService.provisionOrderAppTemplate(ScribeService.groovy:243)
2023-05-18_17:54:07.62091 at com.morpheus.integration.ScribeService$provisionOrderAppTemplate$1.call(Unknown Source)
2023-05-18_17:54:07.62091 at com.morpheus.CatalogItemService.validateCatalogItem(CatalogItemService.groovy:125)
2023-05-18_17:54:07.62092 at com.morpheus.CatalogItemService$validateCatalogItem$8.call(Unknown Source)
2023-05-18_17:54:07.62094 at com.morpheus.personas.serviceCatalog.CatalogController.validateItem(CatalogController.groovy:318)
2023-05-18_17:54:07.62094 at org.grails.core.DefaultGrailsControllerClass$MethodHandleInvoker.invoke(DefaultGrailsControllerClass.java:223)
2023-05-18_17:54:07.62095 at org.grails.core.DefaultGrailsControllerClass.invoke(DefaultGrailsControllerClass.java:188)
2023-05-18_17:54:07.62095 at org.grails.web.mapping.mvc.UrlMappingsInfoHandlerAdapter.handle(UrlMappingsInfoHandlerAdapter.groovy:90)
2023-05-18_17:54:07.62096 at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067)
2023-05-18_17:54:07.62096 at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)
2023-05-18_17:54:07.62096 at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
2023-05-18_17:54:07.62097 at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
2023-05-18_17:54:07.62098 at javax.servlet.http.HttpServlet.service(HttpServlet.java:696)

can you try either container.dateCreated or instance.dataCreated? Using spec looks like there’s no server object

Same error with container.dateCreated and instance.dataCreated

@cbunge any otehr ideas?

I created an Manual Option Lists. and add a JS script to get the current date and time. then created select list input and called that options list…

used this input in catalog item app spect to get the current time.

<%= new Date().format('dd-MM-yyyy')%> may be more simple for you.

1 Like

Thanks @ctaylor, what is the best way to add the date in to Terraform cloud profiles?