Skip to Content
Technical Articles
Author's profile photo PRASHANT SHARMA

Driving Field-Default-Values with Value Type Rules in SAP C4C

“This won’t be feasible without SDK”, I would have told my client, had he thrown at me the same requirement a few months back. Requirement was straight forward, and it said, “Need to display standard Date field in the Opportunity Quick Create screen without a value in it.” Anyone who has worked with the Date Profile in SAP C4C will agree that it only allows us to set a validity period for the opportunity but doesn’t allow displaying the field(s) blank i.e. without a value so this couldn’t be achieved with Date Profile settings. We needed something that overrides system logic.

Till a few months back I’d have felt not so good while talking about this system limitation of not being able to default certain fields dynamically. But not anymore. With the new extensibility feature of Value Type Rule SAP has provided a magic solution to this conundrum. And what one can do with this option, when it comes to defaulting field values, is augmentation to imagination.

While I was yet to go through “what’s new in the new release” list (which by the way can be found here) the timing of this requirement couldn’t be any better. It gave me a chance to work with this feature (just out from SAP’s feature factory),  although I learnt about it the hard way. And in this blog post, I am going to explain how this was done.

This is a wonderful feature and can be put to multiple uses. There is one thing it does really-well and that is helping your client do his/her business better. And that in a nutshell is the whole idea of an enterprise software. If this is something you have been looking for, please continue reading. However if you are already aware of this magical little feature, you are still welcome to read and provide your comments just in case I missed something here which will help me improve my knowledge as well as this blog post.

So, let’s get started.

For this blog post we’ll consider the field Opportunity Close Date. Since I was yet to go through the release notes, I first turned to Date Profile. As per “Date Profile” fine tuning activity, we can default this field to a specific number of days from the Opportunity Creation Date as conveyed in the picture below.

Date%20Profile%20governing%20Opportunity%20Dates

Image Created by Prashant Sharma (Author)

However, by standard, the value can be manipulated based on Date Profile, but it still holds a value. And our aim was to get it displayed with no value to start with.

After I checked all the options in Scoping, Fine- tuning and Administration, I turned to my favorite place, Adaptation Mode.

SAP has done a great job upgrading the system every quarter over the past few years. Many new features have come up and many inconsistencies are gone. If you are also someone who has worked on this application for a few years now, you’d know what I mean when I say, “C4C application is a lot more matured application than what it was 3 years back”. And it continues to evolve.

While going through the field properties, something held my sight. It was the property “Set Default Value”. This was new. Suddenly a ray of hope struck me, and I started thinking, how I could use this property to set a default value for the field and could “no value” be the default value? I tried using it, but it didn’t give me an option to set a default value here (silly, I know!) however I saw the possibility of applying a rule here. But could a rule help me set null value in this field? I was just about to find out.

Looking for an answer to my questions, I headed straight to Rules and what greeted me here was a new Rule Type Code – Value.

Value%20Type%20Rule%20Selection

Image Created by Prashant Sharma (Author)

Now I had to figure out how this Rule Type worked and then apply it. There is no better way to learn than by doing it and so I started writing my rule and for quite some time nothing made much sense as I wasn’t able to figure out how is the Value type rule different from a Property type of rule.

After quite a few trials came my first hit. IF condition seemed to be taking arguments for a value. I tested it and it was working. The system had just given me a tool to deliver the requirement that 3 months back was not feasible, and it was a great feeling.

Look at the screenshot below and notice how the value vanishes based on the arguments in IF condition.

IF%20Condition

Image Created by Prashant Sharma (Author)

Next and final step was to apply this rule to the field. As soon as I did that, the value of the field magically vanished or let me say it was defaulted to null value. Let me give you a glimpse of how it worked below.

Applying%20the%20Value%20Rule

Image Created by Prashant Sharma (Author)

As you see, my condition is based on the Document Type. When I select the Document Type as OPPT the system displays a default value (a date value) in the Close Date field. However as soon as I change the Document Type to Z4, the value in Close Date field vanishes to give me the field without an existing value.

Image Created by Prashant Sharma (Author)

This is what my client needed and when I showed him this he was delighted.

Here is a quick infographic I created to summarize this new extensibility function for you.

Image%20Created%20by%20Prashant%20Sharma%20%28Author%29

Image Created by Prashant Sharma (Author)

 

This little tool can be used in multiple different ways. Here are a few use cases where I have used this successfully. And this is not full list of the uses this can be put to.

  • Default a standard date field (or any other standard or extension field) to show up as blank
  • Default a field to a value of your choice
  • Default the value in a field to be equal to another field e.g. default the currency in an amount field to be the same as any other amount field on the screen so that user doesn’t have to select currency in multiple amount fields

Last but not the least, there are some points to keep in mind while working with this feature

  • Value Type rules are applicable only on Quick Create screens
  • Value Type rules do not work on Value Help fields and Multi-value fields
  • Value Type rules override the existing logic such as Extension Scenarios, SDK script determination, application logic and Code List Restrictions (However, you may have to deal with an error message when you are defaulting to a value that is not allowed in your Code List Restrictions)
  • While writing the code in value rule, the return value must be enclosed in single quotes (unless you want to pick the return value from another field in which case, you’ll just select that field in the rule without single quotes)

This is an account of my own experience and my own perspective of how I used this feature successfully. And this beautiful little feature certainly avoided going to SDK. I hope this was helpful for you in some way. Please feel free to provide your comments or ask questions if you have any and I will be sure to respond to you as soon as I can. Wishing you, my reader, great success in whatever you do and a life full of great health and ubiquitous prosperity and everlasting success.

Thank You!!!

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Syed Qanit Rizvi
      Syed Qanit Rizvi

      Nice Blog Prashant !!!!

      Very well written and nicely captured all the things regarding the default value rules scenario.I must say this will be very helpful for everyone.

      Thanks for sharing the information!!!

       

       

      Author's profile photo PRASHANT SHARMA
      PRASHANT SHARMA
      Blog Post Author

      Thanks a lot Qanit!

      Author's profile photo Abhay Newaskar
      Abhay Newaskar

      Nice Blog and default value rule will simplify typical  abstraction/restriction  levels requirements.