RE: Updating Vendor Address using X++
Hi Chaitanya,
Thank you so much for reply.
we can update logisticpostal address.state.
This piece of code will do
//To Update
VendTable vendtable;
LogisticsPostalAddress postalAddress;
DirPartyLocation partyLocation;
EffectiveDateTime fromdate;
ExpirationDateTime todate;
ttsBegin;
select firstFast vendtable where vendtable.AccountNum == "INMF-000001";
select forUpdate firstOnly postalAddress
exists join partyLocation
where partyLocation.Location == postalAddress.Location
&& partyLocation.IsPrimary == true
&& partyLocation.Party == vendtable.Party;
postalAddress.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);
postalAddress.State = "Andhra";
postalAddress.ValidFrom = DateTimeUtil::getSystemDateTime();
postalAddress.ValidTo = DateTimeUtil::maxValue();
postalAddress.doUpdate();
ttsCommit;
info("Updated");
Relation :-
Vendtable == vendtable::find("INMF-000001");
vendtable.party == dirpartylocation.party;
dirpartylocation.location == logisticspostaladdress.location //Here u will get Multiple Records whether primary and not primary records .Update based on condition.If all need to be updated Use while here
//Upto here it is updated succesfully.
//Go and check in view whether it is updated or not.We didnot update View in code.But it is updated.
//The relation continues
Logisticspostaladdress.recid == dirpartypostaladdressview._recid_logisticspostaladdress //Here it is updated Automatically.No need to update in View.
If i am wrong.Please correct.
Regards.
Have a great day.