Question Status

Verified
ravikanth.patha asked a question on 21 Apr 2013 11:32 PM

Hello Everybody,

I want to update a field in parent record from child record .

Please help me.

 

Reply
Verified Answer
www.crmworldinfo.blogspot.com responded on 21 Apr 2013 11:43 PM

Hi,

For this,you have to add two web reosources from sdk.

location path:

\sdk\samplecode\js\restendpoint\javascriptrestretrievemultiple\javascriptrestretrievemultiple\scripts

Then you have use following code in your own webresource to update any record.

Guid is must, to updating any record.

function GuidRetrieve() {

   var param = Xrm.Page.context.getQueryStringParameters();

   var source = param["_InReplyToId"];

   if (source == undefined)

       return;

   else {

       var EmailGuid = source;

       var email = {};

       email.new_EmailStatus = { Value: 100000001 }; //This is my custom field

       SDK.REST.updateRecord(EmailGuid,email, "Email",

       function () {

           alert(EmailGuid);

       },

       function (error) {

           alert(error.message);

       });

   }

}

 

function

EmailStatus() {

debugger

;

var optionsetControl = Xrm.Page.ui.controls.get("new_substatus"

);

var

options = optionsetControl.getAttribute().getOptions();

var type = Xrm.Page.getAttribute("new_emailstatus"

).getValue();

if

(type == 1) {

optionsetControl.clearOptions();

for (var

i = 0; i < options.length; i++) {

if

(i == 1) {

optionsetControl.addOption(options[i]);

Xrm.Page.data.entity.attributes.get(

"new_substatus").setSubmitMode("always"

);

//Xrm.Page.getAttribute("new_substatus").setSubmitMode("always");

}

 

}

}

else if

(type == 2) {

optionsetControl.clearOptions();

for (var

i = 0; i < options.length; i++) {

if

(i == 2 || i == 3 || i == 4) {

optionsetControl.addOption(options[i]);

Xrm.Page.data.entity.attributes.get(

"new_substatus").setSubmitMode("always"

);

//Xrm.Page.getAttribute("new_substatus").setSubmitMode("always");

}

}

}

}

 

 

www.crmworldinfo.blogspot.com
Reply
www.crmworldinfo.blogspot.com responded on 22 Apr 2013 10:51 PM

function

EmailStatus() {

var optionsetControl = Xrm.Page.ui.controls.get("new_new_status"

);

var

options = optionsetControl.getAttribute().getOptions();

var type = Xrm.Page.getAttribute("new_emailstatus"

).getValue();

if

(Xrm.Page.ui.getFormType() == 2) {

var status = Xrm.Page.getAttribute("new_new_status"

).getValue();

if

(type == 1) {

optionsetControl.clearOptions();

for (var

i = 0; i < options.length; i++) {

if

(i == 1) {

optionsetControl.addOption(options[i]);

}

}

}

else

if

(type == 2) {

optionsetControl.clearOptions();

for (var

i = 0; i < options.length; i++) {

if

(i == 2 || i == 3 || i == 4) {

optionsetControl.addOption(options[i]);

}

}

}

Xrm.Page.getAttribute(

"new_new_status"

).setValue(status);

}

 

 

if

(Xrm.Page.ui.getFormType() == 1) {

if

(type == 1) {

optionsetControl.clearOptions();

for (var

i = 0; i < options.length; i++) {

if

(i == 1) {

optionsetControl.addOption(options[i]);

Xrm.Page.data.entity.attributes.get(

"new_new_status").setSubmitMode("always"

);

}

}

}

else

if

(type == 2) {

optionsetControl.clearOptions();

for (var

i = 0; i < options.length; i++) {

if

(i == 2 || i == 3 || i == 4) {

optionsetControl.addOption(options[i]);

Xrm.Page.data.entity.attributes.get(

"new_new_status").setSubmitMode("always"

);

}

}

}

}

}

www.crmworldinfo.blogspot.com
Reply
www.crmworldinfo.blogspot.com responded on 23 Apr 2013 7:05 AM

function EmailStatus() {

   var optionsetControl = Xrm.Page.ui.controls.get("new_new_status");

   var options = optionsetControl.getAttribute().getOptions();

   var type = Xrm.Page.getAttribute("new_emailstatus").getValue();

   if (type == 1) {

       if (Xrm.Page.ui.getFormType() == 2) {

           var status = Xrm.Page.getAttribute("new_new_status").getValue();

       }

       optionsetControl.clearOptions();

       optionsetControl.addOption(options[1]);

       Xrm.Page.data.entity.attributes.get("new_new_status").setSubmitMode("always");

       if (Xrm.Page.ui.getFormType() == 2) {

           var status = Xrm.Page.getAttribute("new_new_status").setValue(status);

       }

   }

   else if (type == 2) {

       if (Xrm.Page.ui.getFormType() == 2) {

           var status = Xrm.Page.getAttribute("new_new_status").getValue();

       }

           optionsetControl.clearOptions();

           optionsetControl.addOption(options[2]);

           optionsetControl.addOption(options[3]);

           optionsetControl.addOption(options[4]);

           Xrm.Page.data.entity.attributes.get("new_new_status").setSubmitMode("always");

           if (Xrm.Page.ui.getFormType() == 2) {

               var status = Xrm.Page.getAttribute("new_new_status").setValue(status);

           }

       }

}

www.crmworldinfo.blogspot.com
Reply
Verified Answer
www.crmworldinfo.blogspot.com responded on 21 Apr 2013 11:43 PM

Hi,

For this,you have to add two web reosources from sdk.

location path:

\sdk\samplecode\js\restendpoint\javascriptrestretrievemultiple\javascriptrestretrievemultiple\scripts

Then you have use following code in your own webresource to update any record.

Guid is must, to updating any record.

function GuidRetrieve() {

   var param = Xrm.Page.context.getQueryStringParameters();

   var source = param["_InReplyToId"];

   if (source == undefined)

       return;

   else {

       var EmailGuid = source;

       var email = {};

       email.new_EmailStatus = { Value: 100000001 }; //This is my custom field

       SDK.REST.updateRecord(EmailGuid,email, "Email",

       function () {

           alert(EmailGuid);

       },

       function (error) {

           alert(error.message);

       });

   }

}

 

function

EmailStatus() {

debugger

;

var optionsetControl = Xrm.Page.ui.controls.get("new_substatus"

);

var

options = optionsetControl.getAttribute().getOptions();

var type = Xrm.Page.getAttribute("new_emailstatus"

).getValue();

if

(type == 1) {

optionsetControl.clearOptions();

for (var

i = 0; i < options.length; i++) {

if

(i == 1) {

optionsetControl.addOption(options[i]);

Xrm.Page.data.entity.attributes.get(

"new_substatus").setSubmitMode("always"

);

//Xrm.Page.getAttribute("new_substatus").setSubmitMode("always");

}

 

}

}

else if

(type == 2) {

optionsetControl.clearOptions();

for (var

i = 0; i < options.length; i++) {

if

(i == 2 || i == 3 || i == 4) {

optionsetControl.addOption(options[i]);

Xrm.Page.data.entity.attributes.get(

"new_substatus").setSubmitMode("always"

);

//Xrm.Page.getAttribute("new_substatus").setSubmitMode("always");

}

}

}

}

 

 

www.crmworldinfo.blogspot.com
Reply