hey, can anybody tell me how can i use crypto.chec...
# general
v
hey, can anybody tell me how can i use crypto.checkPasswordField on custonmer record to check if the password assigned to a customer matched with password i am entering in another field
b
v
but this is giving true all time
b
what does your attempt look like
v
I have to create suitelet in which user enter email and password and then we have to match that fro NS customer and if we found any customer with that credential we have to return item pricing
b
what does your code look like
v
define(['N/ui/serverWidget','N/search','N/crypto','N/record'], function(serverWidget,search,crypto,record) { function onRequest(context) { try{ if (context.request.method === 'GET') { var form = serverWidget.createForm({ title: 'Simple Form' }); var field1= form.addField({ id: 'username', type: serverWidget.FieldType.EMAIL, label: 'USARNAME' }); field1.layoutType = serverWidget.FieldLayoutType.NORMAL; field1.isMandatory = true; // field1.updateBreakType({ // breakType: serverWidget.FieldBreakType.STARTCOL // }); var field2 = form.addField({ id: 'password', type: serverWidget.FieldType.PASSWORD, label: 'PASSWORD' }); field2.isMandatory = true; form.addSubmitButton({ label: 'Submit Button' }); context.response.writePage(form); } else { var email = context.request.parameters.username; var password = context.request.parameters.password; log.debug("email",email); log.debug("password up",password); var customerSearchObj = search.create({ type: "customer", filters: [ ["email","is",email] ], columns: [ search.createColumn({name: "pricingitem", label: "Pricing Item"}), search.createColumn({name: "itempricinglevel", label: "Item Pricing Level"}), search.createColumn({name: "itempricingunitprice", label: "Item Pricing Unit Price"}) ] }); var searchResultCount = customerSearchObj.runPaged().count; log.debug("customerSearchObj result count",searchResultCount); var mySearchResult = customerSearchObj.run(); var columns =mySearchResult.columns; var arr =[]; log.debug("columns",columns); customerSearchObj.run().each(function(result){ // .run().each has a limit of 4,000 results var id =result.id; log.debug("id",id); log.debug("password",password); var options = { recordType: record.Type.CUSTOMER, recordId: JSON.parse(id), fieldId: 'custentity_pass_', value: password }; log.debug("options",options); if (crypto.checkPasswordField(options)) { log.debug('True'); var pricingitem = result.getValue(columns[0]); var itempricinglevel= result.getValue(columns[1]); var itempricingunitprice = result.getValue(columns[2])||0; var obj ={ "pricingitem":pricingitem, "itempricinglevel":itempricinglevel, "itempricingunitprice":itempricingunitprice }; arr.push(obj); } return ; }); log.debug("return data",arr) context.response.write(JSON.stringify(arr)); } }catch(error){ log.debug("erroe",JSON.stringify(error)); } } return { onRequest: onRequest }; });
here is the code
b
that search code isnt sane
but i dont think there is anything you are doing that would make checkPasswordField return true if the password didnt match
v
oh ignore that filter of search
b
its more likely that you are messing up at the search code
v
please let me know which id , i have to pass in the field id of "options" of checkPasswordField if i want to use it for this field given in screenshot-
message has been deleted
b
go through the docs for checkPasswordField