Hi, would someone be able to point me in the right...
# suitescript
m
Hi, would someone be able to point me in the right direction with ue scripting for customer record address, i want to locate the right address using a postcode, once the address record in the customer's addressbook is located i want to set it as the default billing. where i'm stumbling is 'how does one figure out the line id of the address record' i need it know the line id in order to edit the address record, this block of code i have requires the right line number var subrec = rec.getSublistSubrecord({ sublistId: 'addressbook', fieldId: 'addressbookaddress', line: 0 }); please guide me on how one searches a customer record's address book with a post code, to retrieve the line number for me to use in my code above. much appreciated
b
safe way is to go through each addressbook address and check the zipcode field for the one you are looking for
you also probably want to be more precise in your usage of line id
there is an actual id for the line, and its not the same as the line sequence number
the line parameter used in suitescript is the 0 indexed, line sequence number
m
i could grab the address id, but to update the address default billing flag i believe i'm limited to using getsublistsubrecord, meaning i must get the line id.
b
again, the line in
Copy code
var subrec = rec.getSublistSubrecord({
            sublistId: 'addressbook',
            fieldId: 'addressbookaddress',
            line: 0
        });
isnt the id
its the index
m
yep, that's what i'm struggling to get
b
which means the first addressbook is line 0
m
a saved search can't get line no
b
the second is line 1 and so on
m
Untitled
i attempted the loop
it doesn't work though, i was using the finali as my 'line' number
i didn't manage to make this block work, couldn't retrieve the postcode successfully
b
as in you couldnt loop through the addressbook lines
m
it looped, but it didn't return the postcode to be validated
'i' variable did increment
b
that more likely to be a code problem
m
but never managed to retrieve the postcodes
b
my guess is that you dont know how to inspect the value in cus_pc
m
yeah its my loop problem, in theory the finali variable will be able to act as the line number?
b
start logging cus_pc, or use the debugger to inspect its value
m
i believe it's this bit i need to tidy cusRec.getSublistValue('addressbook', 'postcode', i)
it returns undefined
b
correct, there is no postcode field on the addressbook sublist
m
prob zip
b
its the wrong place to look
and the wrong id
m
how so?
i was hoping for a simple call like findsublinewithvalue()
couldn't find the equivalent, seeing as the postcode hides in a sub list within a sublist
b
its called a subrecord, and you will have to go in there to get to the zip code
i mean, if you wanted to be hacky and use internal fields, you can probably find one for the zip, but thats not really sane when there is a perfectly acceptable non hacky solution
m
yeah, i'll try fix my loop then and see if that works
thanks battk