how can I update only first record?

Hello I have a scenerio like I have to update of current’s Personel Contact Infos.

I have a case that they can add one or more telefon number on vendor infos or customer infos but I have to only select the one of them and then change the IsPrimary field to true.

but my codes update all of it.I just want to update only one, does not matter which one just only the first phone number ad set Isprimary

I wrote code like this but it does update all of it.I have a scenerio like on this picture.

They have different phone numbers (LogisticsElectronicAddressMethodType::Phone)but I have to choose only one of them and set the Isprimary.

How should I do this,plase heple me:

static void electronicaddressUpdate(Args _args)
VendTable VendTable;
CustTable CustTable;
BankAccountTable BankAccountTable;
LogisticsElectronicAddress LogisticsElectronicAddress;


while select forUpdate LogisticsElectronicAddress where LogisticsElectronicAddress.Type==LogisticsElectronicAddressMethodType::Phone


if(VendTable.RecId ==LogisticsElectronicAddress.Location )


else if(CustTable.RecId==LogisticsElectronicAddress.Location)


The above code doesn’t makes any sense. You are setting the IsPrimary to Yes in all the cases. Also you are not selecting the vendTable or custTable buffer and you still using them in your if condition - this will not work.

For updating the only one record you have to use the select instead of while select.

Example: select forUpdate firstonly LogisticsElectronicAddress

oh I see How can I use select statement for this case:

I want to update the phone numbers in logisticselectronics table ,and in logistics electronic table has relation with custtable and vendtable like vendtable.recId==logisticelectonic.Locator ,custTable.recId==logisticselevtronic.locator

they have 1-n relations.
A recId has relations with n Locator.

should I write like for cust and vendTable separately:

select forUpdate firstonly LogisticsElectronicAddress where CustTable.RecId==LogisticsElectronicAddress.Locator

if( LogisticsElectronicAddress.IsPrimary::Noyes::No && LogisticsElectronicAddress.Type=“Phone”)


this relation is not true. There is no direct relation between custTable/VendTable and LogisticsElectronicAddress

You have to use DirPatyLocation to find the relevant LogisticsElectronicAddress. = DirPatyLocation .Party

DirPatyLocation.Locatoin = LogisticsElectronicAddress.Location

Oh I see thank you kranthi for your helps