cancel
Showing results for 
Search instead for 
Did you mean: 

getting a field value from ResponseText

former_member185241
Active Participant
0 Kudos

Hello Expert,

I am calling Create method of oData to create Partners. I attached method attachRequestCompleted to model.

While debugging i can see the response Text from server which contains all the fields of the partner.

My query is how to pick partner field value from response Text so that i could show it in messageToast.

Thanks,

Abhi

Accepted Solutions (1)

Accepted Solutions (1)

junwu
Active Contributor
0 Kudos

is it a json object?

obj.obj.obj.finallyyourproperty

former_member185241
Active Participant
0 Kudos

Hi Jun Wu,

Yes it is in json format. It has everything related to new partner in lncluding its ID.

Your answer is not much clear to me.

thanks,

junwu
Active Contributor
0 Kudos

screenshot the object,

expand it to the level where the attribute is located

former_member185241
Active Participant
0 Kudos

Hello Jun,

Below is the screen shot of the response that i am getting from oDataModel.attachRequestCompleted

responseText :

"{"d":{"__metadata":{"id":"/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/BusinessPartnerSet('0100000070')","uri":":443/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/BusinessPartnerSet('0100000070')","type":"/IWBEP/GWSAMPLE_BASIC.BusinessPartner","etag":"W/\"datetime'2016-08-23T20%3A07%3A15.0270000'\""},"Address":{"__metadata":{"type":"/IWBEP/GWSAMPLE_BASIC.CT_Address"},"City":" blore","PostalCode":" 676","Street":" test","Building":" f2","Country":"IN","AddressType":"02"},"BusinessPartnerID":"0100000070","CompanyName":" Comp","WebAddress":" www.gmail.com","EmailAddress":" emailat@gmail.com","PhoneNumber":" 676876876","FaxNumber":" 676797879","LegalForm":" 676797879","CurrencyCode":"INR","BusinessPartnerRole":"01","CreatedAt":"\/Date(1471982835027)\/","ChangedAt":"\/Date(1471982835027)\/","ToSalesOrders":{"__deferred":{"uri":":443/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/BusinessPartnerSet('0100000070')/ToSalesOrders"}},"ToContacts":{"__deferred":{"uri":":443/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/BusinessPartnerSet('0100000070')/ToContacts"}},"ToProducts":{"__deferred":{"uri":":443/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/BusinessPartnerSet('0100000070')/ToProducts"}}}}"

I have to read BusinessPartnerID from response Text.Response id in JSON format So what is the standard way to pick any field value it ?

Thanks,

Abhi

junwu
Active Contributor
0 Kudos

//get responseText string first then

var data= JSON.parse(responseText);

data.d........until the attribute you want

former_member185241
Active Participant
0 Kudos

Thanks Jun. It solved my issue

Answers (0)