on 2022 Aug 25 4:45 PM
Dear fantastic SAP Community,
I work at the moment with CPQ 2208 & Quote2.0
We wan't to catch the current timestamp in a CustomField of a Quote when a Custom Action will be triggered:
Manny thanks to Yogananda Muthaiah (@yoganandamuthaiah) I tried to follow his blog article with an section about the usage of time date at it end (https://blogs.sap.com/2021/12/31/most-commonly-used-iron-python-functions-in-sap-cpq/) This code works fine...
from datetime import datetime<br>start_time = datetime.now()<br>...<br>end_time = datetime.now()<br>Totaltime = ('Duration: {}'.format(end_time - start_time))
But my following adaptation (for my purpose) produces the Error "can't assign to function call"
from datetime import datetime
Timestamp = datetime.now()
Trace.Write(Timestamp)
FormatedTimestamp = ("{}".format(Timestamp))
Trace.Write(FormatedTimestamp)
context.Quote.GetCustomField("ApprovalModDateCompliance") = FormatedTimestamp<br>
I think the error will becaused by the following code line:
context.Quote.GetCustomField("ApprovalModDateCompliance") = FormatedTimestamp
The Output for Timestamp and FormatedTimestamp can you see here:
2022-08-25 10:32:44.418 (1 ms)Script Execution - Debug run
2022-08-25 10:32:44.418
2022-08-25 10:32:44.418
Local variables in script
-------------------------
Timestamp: datetime (Full type name: IronPython.Modules.PythonDateTime+datetime)
day : 25
hour : 10
microsecond : 418000
minute : 32
month : 8
second : 44
tzinfo : null
year : 2022
-------------------------
FormatedTimestamp: String (Full type name: System.String)
value : 2022-08-25 10:32:44.418000
-------------------------
I have tried a lot of code variants and I didn't found a solution for it, but maybe someone of you know the right code to pass a datetime in a custom field of a quote with the format Date.
Do you have a working version of that code snipet or a hint how to fix it?
Look forward to your support 🙂
Kind regards
Alexander
Request clarification before answering.
Solved by the direct comment of:
lukapilipovic
Many thanks also for the reply to:
yoganandamuthaiah and
The answer which worked for my issue was:
from System import DateTime
CurrentDate = DateTime.Now
context.Quote.GetCustomField("ApprovalModDateCompliance").Value = CurrentDate
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
import datetime
today_date = datetime.date.today()
print(today_date)
new_today_date = today_date.strftime("%d/%m/%Y")
print (new_today_date)
context.Quote.GetCustomField("Quote Expiration Date").Value = new_today_date
use this for quote 2.0 alexander-maerz lukapilipovic
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello alexander-maerz ;
Could you try below code;
from System import DateTime
CurrentDate = DateTime.Now
context.Quote.GetCustomField("ApprovalModDateCompliance").Content = CurrentDate
I think you should put ".Content" after context.Quote.GetCustomField("ApprovalModDateCompliance").
Best regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mehmet!
first of all: Wow thank you very much for your fast reply 🙂
I have tried your code sniped. Unfortunately the following error occured:
'Quote2CustomField' object has no attribute 'Content'
I have also tried with the custom field format free form but it the same error is the same 😕
Kind regards
Alexander
alexander-maerz
you can close this question
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
6 | |
2 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.