5
 Followers
28
 Likes

RecordClear Action

Service Studio
On our radar
Like ListClear action there should be one for records.
With just one action and just passing the record name as argument it could set the record attributes to the default values. 

This would be easier, faster and much cleaner than setting all attributes one by one or assigning the record to a blank one. 
Created on 11 Mar 2015
Comments (26)
I learned this the hard way, turns out that assigning a blank record doesn't work so well when iterating over a record list in a loop, record assignments are by reference, not by value!

J.Ja
J.JA, though this is maybe not the right place to discuss it, record assignments are definitely not by reference. Record list assignments are, perhaps you are mixing them up? We have dozens of for eaches in our code that use an empty record to assign to the one that's used to ListAppend to a list that's build.

As for the original idea, the problem would be that records are passed by value, so you can't have an actual Action to clear a record. Under the hood the default values of a record are part of the record's constructor, so you need to create a new one and assign that to the old one to clear the old one. But it would be nice to be able to have an easier way than to do it manually, even if I can't think of a good way to implement it on a functional level that's technically also possible.
Kilian -

You're right... in this case, what messed us up was that the record contained an Attribute of type Record List... that's what was getting messed up... been a long week!

J.Ja
@Kilian


Internally the RecordClear action could create a new instance of the object and assign it to our existing variable. Or, .NET has the default keyword that coud also be used for this case:

https://msdn.microsoft.com/en-us/library/xwth0h0d.aspx
Still, you'd need to assign the record to the clear function that has the record as parameter. That could work, but looks a bit odd.
Merged this idea with '"nullRecord" - be able to clear a record' (created on 20 Nov 2018 15:59:37 by Fernando Dinis)


I have a structure that is populated within a foreach loop. At a certain point (in each cycle interaction) I have to clear the attribues of this structure. The idea I propose will be to be able to clear the variable through a "nullRecord" instead of doing an assignment where I am putting "null" for each attribute of the record.

Thank you.



This comment was:
- originally posted on idea '"nullRecord" - be able to clear a record' (created on 20 Nov 2018 by Fernando Dinis)
- merged to idea 'RecordClear Action' on 16 Apr 2019 18:59:14 by Justin James

Hi Fernando,

There's already a way to do that, creating an extra variable whose type is the structure and assigning it to the main variable to clear it. 

Does this work for you?


Cheers!



This comment was:
- originally posted on idea '"nullRecord" - be able to clear a record' (created on 20 Nov 2018 by Fernando Dinis)
- merged to idea 'RecordClear Action' on 16 Apr 2019 18:59:14 by Justin James

Hi Ricardo,


In fact that was the way that I did but seems to me that if we just assign our records to null it would be more intuitive.

Thanks for your feedback  ;)



This comment was:
- originally posted on idea '"nullRecord" - be able to clear a record' (created on 20 Nov 2018 by Fernando Dinis)
- merged to idea 'RecordClear Action' on 16 Apr 2019 18:59:14 by Justin James

Or a "RecordClear" function like there is "ListClear"? That would be nice and obvious what is happening and why.

J.Ja



This comment was:
- originally posted on idea '"nullRecord" - be able to clear a record' (created on 20 Nov 2018 by Fernando Dinis)
- merged to idea 'RecordClear Action' on 16 Apr 2019 18:59:14 by Justin James

Yes Justin, that could be awesome as well.

Thanks



This comment was:
- originally posted on idea '"nullRecord" - be able to clear a record' (created on 20 Nov 2018 by Fernando Dinis)
- merged to idea 'RecordClear Action' on 16 Apr 2019 18:59:14 by Justin James

Changed the category to Service Studio and the status to

On our radar


Thanks for the idea Fernando



This comment was:
- originally posted on idea '"nullRecord" - be able to clear a record' (created on 20 Nov 2018 by Fernando Dinis)
- merged to idea 'RecordClear Action' on 16 Apr 2019 18:59:14 by Justin James
Merged this idea with 'Null Assignment - Should be able to assign null to object' (created on 13 Apr 2019 15:12:48 by Sravan Vanteru)

This comment was:
- originally posted on idea '"nullRecord" - be able to clear a record' (created on 20 Nov 2018 by Fernando Dinis)
- merged to idea 'RecordClear Action' on 16 Apr 2019 18:59:14 by Justin James

Currently systems not allowing to assign null values to object and not able to assign empty to list variable as well.

Good to have null and empty assignments, it will be very useful when looping through objects.



This comment was:
- originally posted on idea 'Null Assignment - Should be able to assign null to object' (created on 13 Apr 2019 by Sravan Vanteru)
- merged to idea '"nullRecord" - be able to clear a record' on 16 Apr 2019 18:54:33 by Justin James


This comment was:
- originally posted on idea '"nullRecord" - be able to clear a record' (created on 20 Nov 2018 by Fernando Dinis)
- merged to idea 'RecordClear Action' on 16 Apr 2019 18:59:14 by Justin James

I miss null too sometimes. There are things like NullIdentifier() and NullTextIdentifier() but they are not real nulls. 



This comment was:
- originally posted on idea 'Null Assignment - Should be able to assign null to object' (created on 13 Apr 2019 by Sravan Vanteru)
- merged to idea '"nullRecord" - be able to clear a record' on 16 Apr 2019 18:54:34 by Justin James


This comment was:
- originally posted on idea '"nullRecord" - be able to clear a record' (created on 20 Nov 2018 by Fernando Dinis)
- merged to idea 'RecordClear Action' on 16 Apr 2019 18:59:14 by Justin James

This is an extremely deliberate decision:

https://www.outsystems.com/blog/outsystems-decreases-development-risk.html

J.Ja



This comment was:
- originally posted on idea 'Null Assignment - Should be able to assign null to object' (created on 13 Apr 2019 by Sravan Vanteru)
- merged to idea '"nullRecord" - be able to clear a record' on 16 Apr 2019 18:54:34 by Justin James


This comment was:
- originally posted on idea '"nullRecord" - be able to clear a record' (created on 20 Nov 2018 by Fernando Dinis)
- merged to idea 'RecordClear Action' on 16 Apr 2019 18:59:14 by Justin James

Hi Sravan,

What kind of "objects" do you want to assign null to?

And for Lists there's the ListClear Action, why would you want to assign it an "empty value"?



This comment was:
- originally posted on idea 'Null Assignment - Should be able to assign null to object' (created on 13 Apr 2019 by Sravan Vanteru)
- merged to idea '"nullRecord" - be able to clear a record' on 16 Apr 2019 18:54:34 by Justin James


This comment was:
- originally posted on idea '"nullRecord" - be able to clear a record' (created on 20 Nov 2018 by Fernando Dinis)
- merged to idea 'RecordClear Action' on 16 Apr 2019 18:59:14 by Justin James

I'm always creating a "Null Object" (local variable with nothing assigned) to be able to clear out everything from a structure.



This comment was:
- originally posted on idea 'Null Assignment - Should be able to assign null to object' (created on 13 Apr 2019 by Sravan Vanteru)
- merged to idea '"nullRecord" - be able to clear a record' on 16 Apr 2019 18:54:34 by Justin James


This comment was:
- originally posted on idea '"nullRecord" - be able to clear a record' (created on 20 Nov 2018 by Fernando Dinis)
- merged to idea 'RecordClear Action' on 16 Apr 2019 18:59:14 by Justin James

Hi Kilian Hekhuis,

I have loop where I'm going through each object and doing some operation and every time my after my operation I want to assign object to null, but it throwing error error.

1. Declared Variable

 

2. While assignment I'm getting below error.


3. Only way I'm able to solve this scenario is by declaring new variable and use it in assignment.


This way I'm able to proceed further.


Do we have any better solution available ?



This comment was:
- originally posted on idea 'Null Assignment - Should be able to assign null to object' (created on 13 Apr 2019 by Sravan Vanteru)
- merged to idea '"nullRecord" - be able to clear a record' on 16 Apr 2019 18:54:34 by Justin James


This comment was:
- originally posted on idea '"nullRecord" - be able to clear a record' (created on 20 Nov 2018 by Fernando Dinis)
- merged to idea 'RecordClear Action' on 16 Apr 2019 18:59:14 by Justin James

Hi Rebecca Hall,

Exactly.. I'm doing same thing.


Sravan



This comment was:
- originally posted on idea 'Null Assignment - Should be able to assign null to object' (created on 13 Apr 2019 by Sravan Vanteru)
- merged to idea '"nullRecord" - be able to clear a record' on 16 Apr 2019 18:54:34 by Justin James


This comment was:
- originally posted on idea '"nullRecord" - be able to clear a record' (created on 20 Nov 2018 by Fernando Dinis)
- merged to idea 'RecordClear Action' on 16 Apr 2019 18:59:14 by Justin James

Hi Sravan,

When it comes to Structures, that's indeed the easiest way to do it (like Rebecca explained).



This comment was:
- originally posted on idea 'Null Assignment - Should be able to assign null to object' (created on 13 Apr 2019 by Sravan Vanteru)
- merged to idea '"nullRecord" - be able to clear a record' on 16 Apr 2019 18:54:34 by Justin James


This comment was:
- originally posted on idea '"nullRecord" - be able to clear a record' (created on 20 Nov 2018 by Fernando Dinis)
- merged to idea 'RecordClear Action' on 16 Apr 2019 18:59:14 by Justin James

Sorry Guys,

I would have mentioned proper description specific to structures assignment.

Now I don't have option to modify Idea.


Sravan



This comment was:
- originally posted on idea 'Null Assignment - Should be able to assign null to object' (created on 13 Apr 2019 by Sravan Vanteru)
- merged to idea '"nullRecord" - be able to clear a record' on 16 Apr 2019 18:54:34 by Justin James


This comment was:
- originally posted on idea '"nullRecord" - be able to clear a record' (created on 20 Nov 2018 by Fernando Dinis)
- merged to idea 'RecordClear Action' on 16 Apr 2019 18:59:14 by Justin James

I do what Rececca does, but a simple way of doing it without having to create a new variable would be good.


Either an action or a dummy NullObject() value you assign that causes outsystems to create a new empty variable behind the scenes and apply it.



This comment was:
- originally posted on idea 'Null Assignment - Should be able to assign null to object' (created on 13 Apr 2019 by Sravan Vanteru)
- merged to idea '"nullRecord" - be able to clear a record' on 16 Apr 2019 18:54:34 by Justin James


This comment was:
- originally posted on idea '"nullRecord" - be able to clear a record' (created on 20 Nov 2018 by Fernando Dinis)
- merged to idea 'RecordClear Action' on 16 Apr 2019 18:59:14 by Justin James

NullObject() wouldn't be good for two reasons:

  1. There's actually an Object data type, which is not a Structure;
  2. NullObject() wouldn't have an actual data type, as it could be assigned to any Structure or Entity.

But I agree having something to "clear" a Structure/Entity would be good.



This comment was:
- originally posted on idea 'Null Assignment - Should be able to assign null to object' (created on 13 Apr 2019 by Sravan Vanteru)
- merged to idea '"nullRecord" - be able to clear a record' on 16 Apr 2019 18:54:34 by Justin James


This comment was:
- originally posted on idea '"nullRecord" - be able to clear a record' (created on 20 Nov 2018 by Fernando Dinis)
- merged to idea 'RecordClear Action' on 16 Apr 2019 18:59:14 by Justin James

I was using that as an example.  Try "NullEntity()" then that outsystems automatically applies the right entity type to behind the scenes based on what is being set.



This comment was:
- originally posted on idea 'Null Assignment - Should be able to assign null to object' (created on 13 Apr 2019 by Sravan Vanteru)
- merged to idea '"nullRecord" - be able to clear a record' on 16 Apr 2019 18:54:34 by Justin James


This comment was:
- originally posted on idea '"nullRecord" - be able to clear a record' (created on 20 Nov 2018 by Fernando Dinis)
- merged to idea 'RecordClear Action' on 16 Apr 2019 18:59:14 by Justin James

1. This isn't really about "NullObject", this is about "ThingClear".

2. There's already an idea out there for what amounts to "ThingClear".

I will merge.

J.Ja



This comment was:
- originally posted on idea 'Null Assignment - Should be able to assign null to object' (created on 13 Apr 2019 by Sravan Vanteru)
- merged to idea '"nullRecord" - be able to clear a record' on 16 Apr 2019 18:54:34 by Justin James


This comment was:
- originally posted on idea '"nullRecord" - be able to clear a record' (created on 20 Nov 2018 by Fernando Dinis)
- merged to idea 'RecordClear Action' on 16 Apr 2019 18:59:14 by Justin James
views
1090
Followers
5