Question

To set default value of a non-db field


Userlevel 4
Badge +11

Hi,

how can I set default value of a non-db field?

Ex: want to set def-value REOCCURRING = ‘N’, def-value EXCLUDE_WEEKEND = ‘Y’

 

I have tried by making these actions (individually and combined), but have not succeeded.

  • create a custom view which has fields REOCCURRING and EXCLUDE_WEEKEND.  Default values were set.

View definition is like

CREATE view … AS

SELECT …

, ‘N’  AS REOCCURRING

, ‘Y’ AS EXCLUDE_WEEKEND

--

  • in UI Designer set the respective default values
  • create client script ( (>>calling setControlValue command, client-type = Web Client Only) and attach to the screen AfterScreenLoad event

 

 

 Thanks in advance for your enlightenment. :-)

 

Cheers,

~Juni


10 replies

Userlevel 6
Badge +26

Hey @JuniSihombing 

Have you tried a client script? It is working for me.

For example, I took the ‘DISTANCE’ base line field

 

Cheers!

Userlevel 4
Badge +11

Hi @Shneor Cheshin,

 

thanks for your feedback.

 

Yes, I have tried using client script (using same function setControlValue).

 

The only difference is, the fields to set are from a view.  They are dummy fields.

The reason I don’t use the field from a table because those fields are used only in UI and flags for process in other client-script.

So the idea is not to use up fields of a (baseline) table.

 

Is it possible to achieve that?

 

Cheers,

~Juni.

 

Userlevel 6
Badge +26

Hey @JuniSihombing 

I think you will need to add the view to custom metadata.

Cheers!

Userlevel 7
Badge +22

Hi @JuniSihombing,

Either way, as the primary table does not persist these particular columns in the database, isn’t it possible to directly refer the columns from the view itself by creating the custom metadata for the view  and then joining the view with the primary table keys on the UI designer? Once this is done, you can simply drag and drop the required fields to the ui from the view’s custom metadata and ideally it should show the correct results. 

Userlevel 4
Badge +11

Hi @Saranga Amaraweera

yes, I have done the same as you suggested, but still doesn’t set the default value.

 

Cheers,

~Juni 

Userlevel 4
Badge +11

Hi @Shneor Cheshin ,

custom metadata of the view was created.  In custom metadata default value of the field was also set.

@Saranga Amaraweera’s suggestion was also set before, but the field still cannot get default value set.

 

I thought it was because of “CHECKBOX” field type.  I tried to change the field type to TEXTBOX and removed the masktype  = “YORN” from metadata, but still no default value.

~Juni

Userlevel 7
Badge +22

Hi @JuniSihombing ,

Could you share your view and how you have joined the view with your primary table ?

Userlevel 4
Badge +11

Hi @Saranga Amaraweera,

sorry for the late reply.

 

Here is setting in UI designer:

 

 the setup of field REOCCURRING in custom-metadata:

 

Here is the statement for view:

CREATE VIEW [dbo].[c_exc_mgmt] as
SELECT 
 exception_id as exception_id,
 DATEDIFF(HOUR, start_dttm, end_dttm) as duration,
 DATEPART(WK,start_dttm) -1 as week,
 DATEPART(YY,start_dttm) as year,
 CONCAT (DATEPART(WK,start_dttm)-1,' - ', DATEPART(YY,start_dttm)) as weekyear,
 NULL as reoccurring,
 NULL as exclude_weekend
FROM person_cal_except

 

I did try to set the default values of reoccurring and exclude weekend fields (in the create view statement), but also didn’t work in the runtime.

 ‘N’ as reoccurring,
 ‘Y’ as exclude_weekend

 

Any thoughts based on the setups?

 

Cheers,

~Juni

Userlevel 7
Badge +22

Hi @JuniSihombing ,

Looking at the metadata of your view, you have not enabled the In Database check box for the column that you have shown in the screenshot. This should be ticked for all the fields otherwise, it would not display your view’s results even though you have managed to map the keys with the primary table on the ui designer. Please make sure to check the in database option for all the columns in metadata although it’s a view. Also another question, can you explain the reason why have you put NULL as reoccuring / NULL as exclude_weekend? Aren’t those fields need to be set up according to a logic? May a CASE WHEN statement? 

Userlevel 4
Badge +11

Hi @Saranga Amaraweera ,

 “In Database” flag was also marked, but same result.

 

I set “NULL” for reoccurring/exclude_weekend fields in the view, because just don’t want to give wrong information in the result of view itself.

The exception calendar can be weekend, but if the “exclude_weekend” in view = ‘Y’, the view give not too precise info. 

Reply