How is your experience with the OutSystems Community?
23
Views
6
Comments
Solved
Api request for empty number field
Question


Hi All,

The number fields fax on the screen but in api as a text,If I do not enter anything on screen for fax number in api it is going as "0".

But Other fields ex phone number of type phone on screen and in api as a text ,If we do not enter any thing in phone number on screen ,The filed does not go in request to api,

Then why the fax number is going as "0"-Ideally want to skip the field in request if empty 

Please suggest

2021-09-06 15-09-53
Dorine Boudry
 
MVP
Solution

You are now putting in that api input the boolean result of a condition (converted into text automatically by OutSystems.

It should be something like

If(Party.Faxnumber = 0 , "", Party.FaxNumber)

this, in combination with 'Send Default' = NO will only send the faxnumber if it is different from 0

2024-02-16 11-58-28
Sheikh Mohd Fahad

Hey @Preeti zade,

Please check your API structure and set the "Send Default Value" attribute to "No" in the Advanced section of the API structure.

This ensures that the attribute will not be sent in the request when its value is empty.

Also, before sending the request, add a check for the Fax Number field. 
If the Fax Number is 0, empty (""), or null, do not map/send the attribute in the request payload.


UserImage.jpg
Preeti zade

Hi @Sheikh Mohd Fahad 

I have checked ,The send default value is NO already

and the fax is Number field on the screen not to enter text value and in api the field is Text.

while sending to api,this is also added,

But request goes as below,

"fax_number":"True"

If I dont add above condition,then request goes as

"fax_number":"0"



2021-09-06 15-09-53
Dorine Boudry
 
MVP
Solution

You are now putting in that api input the boolean result of a condition (converted into text automatically by OutSystems.

It should be something like

If(Party.Faxnumber = 0 , "", Party.FaxNumber)

this, in combination with 'Send Default' = NO will only send the faxnumber if it is different from 0

UserImage.jpg
Preeti zade

Thank you Dorine,Its working.

 But did not get as for other phone type variables no need to set any of these conditions and they are going as blank as expected.

Regards

2021-09-06 15-09-53
Dorine Boudry
 
MVP

You should study the data types and their properties. Experiment a little.  You will learn a lot.

2024-10-05 13-30-20
Huy Hoang The

You set :

send default value = No

and this fields is not mandatory

so when api call, if the field null, api auto remove this key-value

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.