Cannot Read Trim of Undefined Query Data Store

Microsoft Dynamics CRM Forum

Ezgi Haglund picture

Cannot read property 'trim' of undefined on PhoneCall Form while setting another field with "to"

How-do-you-do all,

I am trying to set a lookup(account) field with "to" field on phonecall form. Simply while setting it I go this post-obit error bulletin.

"TypeError: Cannot read property 'trim' of undefined
at Function.Number._parse (crm.arvento.com/.../global.ashx)
at Function.Number.parseInvariant (crm.arvento.com/.../global.ashx)
at Mscrm.TurboForm.Control.ViewModel.QuickFormViewModel.$Gh_4 (crm.arvento.com/.../formcontrols.js)
at crm.arvento.com/.../global.ashx
at crm.arvento.com/.../global.ashx
at Mscrm.TurboForm.Command.Data.LookupDataAttribute.fireOnChangeInternal (crm.arvento.com/.../formcontrols.js)
at Mscrm.TurboForm.Control.Information.LookupDataAttribute.setValueInternal (crm.arvento.com/.../formcontrols.js)
at Mscrm.TurboForm.Control.Data.LookupDataAttribute.setValue (crm.arvento.com/.../formcontrols.js)
at Mscrm.FormControls.ClientApi.XrmTurboFormEntityAttributeLookup.setValue (crm.arvento.com/.../formcontrols.js)
at setMusteriDetails (crm.arvento.com/.../new_telefonGorusmesi)"

and here is my js code;

role ToOnChange(){ var to = Xrm.Page.getAttribute("to").getValue(); if (to != null) {         if (to[0] != undefined) {             if (to[0].entityType == "account") {                 var toId= to[0].id.toString().replace("{", "").supersede("}", "");                 setMusteriDetails(toId);             }         }     } }  office setMusteriDetails(toId) {     if (toId!= null) {         //recollect musteri detail         var queryMusteri = "accounts(" + toId+ ")?$select=emailaddress1,_new_bayi_value,_new_bolge_value,_new_sehir_value,_new_ulke_value,proper noun";         var resultMusteri = RestBuilder("GET", queryMusteri);         var emailAddress = resultMusteri["emailaddress1"];         var bayiId = resultMusteri["_new_bayi_value"];         var bayiAdi = resultMusteri["_new_bayi_value@OData.Community.Display.V1.FormattedValue"];         var bolgeId = resultMusteri["_new_bolge_value"];         var bolgeAdi = resultMusteri["_new_bolge_value@OData.Community.Display.V1.FormattedValue"];         var sehirId = resultMusteri["_new_sehir_value"];         var sehirAdi = resultMusteri["_new_sehir_value@OData.Community.Display.V1.FormattedValue"];         var ulkeId = resultMusteri["_new_ulke_value"];         var ulkeAdi = resultMusteri["_new_ulke_value@OData.Community.Display.V1.FormattedValue"];                    var toName= resultMusteri["proper noun"];                    //prepare musteri item                Xrm.Folio.getAttribute("new_email").setSubmitMode("always");         Xrm.Page.getAttribute("new_email").setValue(emailAddress);         Xrm.Page.getAttribute("new_bayi").setSubmitMode("always");         Xrm.Page.getAttribute("new_bayi").setValue([{ id: bayiId, name: bayiAdi, entityType: "new_bayi" }]);         Xrm.Folio.getAttribute("new_bolge").setSubmitMode("always");         Xrm.Page.getAttribute("new_bolge").setValue([{ id: bolgeId, proper name: bolgeAdi, entityType: "new_bolge" }]);         Xrm.Page.getAttribute("new_sehir").setSubmitMode("ever");         Xrm.Page.getAttribute("new_sehir").setValue([{ id: sehirId, proper noun: sehirAdi, entityType: "new_sehir" }]);         Xrm.Page.getAttribute("new_ulke").setSubmitMode("always");         Xrm.Folio.getAttribute("new_ulke").setValue([{ id: ulkeId, name: ulkeAdi, entityType: "new_ulke" }]);                    Xrm.Folio.getAttribute("new_musteri").setSubmitMode("always");         Xrm.Page.getAttribute("new_musteri").setValue([{ id: toId, name: toName, entityType: "account" }]);                    //prepare bayi telefon         var queryBayi = "new_bayis(" + bayiId + ")?$select=new_tel";         var resultBayi = RestBuilder("GET", queryBayi);         var bayiTel = resultBayi["new_tel"];         if (bayiTel != null) {             Xrm.Page.getAttribute("new_bayitelefon").setValue(bayiTel);         }     } }

It works fine if I delete the code sets new_musteri field. I wonder why I get that error.
I really appreciate any assist.

Thanks!

Replies (7)

Gopalan Bhuvanesh picture

Cannot read property 'trim' of undefined on PhoneCall Form while setting another field with "to"

Hi

Looks similar toId is null.

Bank check for the value for toId, while debugging.

Add a condition similar to

if(toId != zip)

{

Xrm.Page.getAttribute("new_musteri").setSubmitMode("always");

Xrm.Page.getAttribute("new_musteri").setValue([{ id: toId, name: toName, entityType: "account" }])

}

Ezgi Haglund picture

Cannot read property 'trim' of undefined on PhoneCall Class while setting some other field with "to"

Hi Gopalan,

When I debug it, it returns the toId and I already have a command on top of my second function (setMusteriDetails).

Lakshmisha Shetty picture

Cannot read holding 'trim' of undefined on PhoneCall Class while setting another field with "to"

Howdy Ezgi,

I recollect your non able to find the control "new_musteri"  in your form. make sure that this field exist in the form and it is named correctly. And its non set every bit hidden.

To avoid the mistake its always a best practice to use the naught check earlier assigning value to whatsoever control.

Mark as Answer if it helps you.

Gopalan Bhuvanesh picture

Cannot read property 'trim' of undefined on PhoneCall Form while setting some other field with "to"

You are using account lookup field new_musteri in the phonecall grade.

Please check the value of toName.

Effort difficult coded values for toId, toName in the following

Xrm.Folio.getAttribute("new_musteri").setValue([{ id: toId, name: toName, entityType: "account" }])

Ezgi Haglund picture

Cannot read property 'trim' of undefined on PhoneCall Form while setting some other field with "to"

Hello Lakshmisha,

I controlled information technology once again but no luck. Btw it sets the field but however pops up this error. I feel like it might be bc you can pick more than ane record for to field on phonecall class but I have no thought how to prevent it.

Lakshmisha Shetty picture

Cannot read property 'trim' of undefined on PhoneCall Form while setting another field with "to"

How-do-you-do Ezgi,

Are you still getting the same fault?

Make sure that toID which ur setting is bachelor in Account entity.

Ezgi Haglund picture

Cannot read property 'trim' of undefined on PhoneCall Class while setting another field with "to"

I have created a new lookup(account) filed merely with a different name than new_musteri and now it works fine.

Thank you lot all for taking the time to help me.

Ezgi Haglund picture

Cannot read holding 'trim' of undefined on PhoneCall Form while setting another field with "to"

I have created a new lookup(account) filed but with a dissimilar name than new_musteri and at present it works fine.

Thank you all for taking the time to help me.

Gopalan Bhuvanesh picture

Cannot read holding 'trim' of undefined on PhoneCall Form while setting another field with "to"

Hello

Looks like toId is null.

Check for the value for toId, while debugging.

Add together a status similar to

if(toId != null)

{

Xrm.Folio.getAttribute("new_musteri").setSubmitMode("ever");

Xrm.Page.getAttribute("new_musteri").setValue([{ id: toId, name: toName, entityType: "account" }])

}

Lakshmisha Shetty picture

Cannot read property 'trim' of undefined on PhoneCall Form while setting some other field with "to"

Hi Ezgi,

I call up your not able to find the command "new_musteri"  in your form. brand certain that this field exist in the class and it is named correctly. And its non set as hidden.

To avoid the fault its always a best practice to use the null cheque before assigning value to whatever control.

Marker as Respond if it helps you lot.

Gopalan Bhuvanesh picture

Cannot read property 'trim' of undefined on PhoneCall Form while setting another field with "to"

You are using account lookup field new_musteri in the phonecall form.

Delight check the value of toName.

Try difficult coded values for toId, toName in the post-obit

Xrm.Page.getAttribute("new_musteri").setValue([{ id: toId, name: toName, entityType: "account" }])

Lakshmisha Shetty picture

Cannot read holding 'trim' of undefined on PhoneCall Form while setting another field with "to"

Hullo Ezgi,

Are you even so getting the same fault?

Make certain that toID which ur setting is available in Account entity.

woodarecow84.blogspot.com

Source: https://community.dynamics.com/crm/f/microsoft-dynamics-crm-forum/236486/cannot-read-property-trim-of-undefined-on-phonecall-form-while-setting-another-field-with-to/649078

0 Response to "Cannot Read Trim of Undefined Query Data Store"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel