web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Error de Script- Where it's?

(0) ShareShare
ReportReport
Posted on by

cer.png

Hello everybody! 

I've a question about it ^

I know that we've "system scripts" and "user scripts" (that we made)... When I make my scripts, somes days afthers I get this error but somes times.... For example in 3 month I get that only 4 times and today I was able to make a picture (because the others 3 was with others Users, this time was to me).

My dude is: Where is this "Anonymous Function"? I've reseaching in all sites and don't look any function with this name.... and what I must do with this?? (desactivate this script??? or add the fields that this script need in invisible section?).

Thanks.

*This post is locked for comments

I have the same question (0)
  • Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    Click on the Download Log File (Descargar Archivo...) in the error message to get additional details about the actual error. If you don't find the error helpful, please paste it in this question.

    Seems like your error is in a web resource file, so you can also debug it using your browser developer tools (F12).

    Hope this helps.

  • Ummacrm Profile Picture
    270 on at

    There is a problem in your script.  You may not see it unless you execute the function; i.e., perform the action that would fire the code, such as on-change of a field, which is why it only happens on occasion.  The problem has something to do with the 'then' statement.  Debugging using your browser would be the best bet as Aric mentions.

    There  will be nothing named "Anonymous Function" for you to find.   Here you can learn more about what is meant by "Anonymous Function": helephant.com/.../javascript-anonymous-functions

  • Community Member Profile Picture
    on at

    Thanks to boths, but it's very hard to "debugg it" because like I said... in 3 month I only get this 4 times, so I don't know when will be the 5° to have the debugging active.

    And like you post there, the anonymous function are very complex to find (hahahaha :c).

    I've tried set values to all fields (to see if there's any Onchange) but nothing.... the first time was a User when create her fisrt account (afther that she never get this error), the second was in opportunity (open), the third was a lead (open) and this last was saving an opportunity (in the second stage...)

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Maurizio ,

    The error is coming from your web resource , as some object are getting null. So its not getting "then" property.

    Could you please add one null check before doing the operation "then" like below.

    if(someobj != null)

    {

    someobj.then(.......);

    }

  • Community Member Profile Picture
    on at

    I must add this in my script? and if it's "yes" it'll be an OnLoad, OnChange or OrSaved Event?

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Maurizio,

    I am not sure which event your function is triggering , just open the web resource from setting--> customize the system -->. Web Resource--> Find the web resource mentioned in the error-->Open the web resource -->Go to the function where you have written "then" statement and add this null check.

    Once done update the web resource and publish.

  • Community Member Profile Picture
    on at

    Hello there, I've there somes dudes....

    1) I've read all scripts (that can personalizate made with me or the system), nobody has a "Anonymous Function".

    2) In one personal script we have this: Xrm.Page.data.entity.save().then(successCallback, errorCallback);

    But it's use in the script only when the "If Sentece" is Oks.

    Example (This is for the first Stage in Opportunity):

    if (StageName === "Etapa 1- Identificar Prospecto"){
    
    var backstage = Xrm.Page.data.process.getSelectedStage();
    
    var manic = Xrm.Page.getAttribute("mk_manact_inicial").getValue();
    
    var reuini = Xrm.Page.getAttribute("mk_reunion_inicial").getValue();
    	
    var onHoldUno = Xrm.Page.getAttribute("mk_on_hold").getValue();
    	
    var PerdidaUno = Xrm.Page.getAttribute("mk_perdida").getValue();
    
    Xrm.Page.getAttribute("mk_fase_proceso").setValue(StageAName);
    	
    // Pediremos que en St1 (inicial) setee los SetR# a Falsos 
    var SetR1 = Xrm.Page.getAttribute("mk_activar_requerido_1").setValue(false);
    var SetR2 = Xrm.Page.getAttribute("mk_activar_requerido_2").setValue(false);
    var SetR3 = Xrm.Page.getAttribute("mk_activar_requerido_3").setValue(false);
    var SetR4 = Xrm.Page.getAttribute("mk_activar_requerido_4").setValue(false);
    var SetR5 = Xrm.Page.getAttribute("mk_activar_requerido_5").setValue(false);
    var SetR1 = Xrm.Page.getAttribute("mk_activar_requerido_1").getValue();
    var SetR2 = Xrm.Page.getAttribute("mk_activar_requerido_2").getValue();
    var SetR3 = Xrm.Page.getAttribute("mk_activar_requerido_3").getValue();
    var SetR4 = Xrm.Page.getAttribute("mk_activar_requerido_4").getValue();
    var SetR5 = Xrm.Page.getAttribute("mk_activar_requerido_5").getValue();
    console.log("SetR1" + SetR1);
    console.log("SetR2" + SetR2);
    console.log("SetR3" + SetR3);
    console.log("SetR4" + SetR4);
    console.log("SetR5" + SetR5);
    
    var StageIdUno = StageSelect.getId();
    console.log("Id Stage1" + StageIdUno);
    
    // Guardaremos var Desca1 mk_descalifica_1
    //var Desca1 = Xrm.Page.getAttribute("mk_descalifica_1").getValue();
    	
    if((manic == false) ||(reuini == false) ){
    
    moveToNext = false;
    
    }
    
    if (moveToNext) {
    
       //Move to the next stage y VISTA
    
     Xrm.Page.data.process.moveNext(function (status)
    
    {
    
    console.log(status);
    
    console.log(Xrm.Page.ui.getFormType());
    
    if (Xrm.Page.ui.getFormType() == 1 && status == "invalid")
    
    {
    
    Xrm.Page.data.entity.save().then(successCallback, errorCallback);
    
    function successCallback()
    
    {
    
    Xrm.Utility.openEntityForm(Xrm.Page.data.entity.getEntityName(), Xrm.Page.data.entity.getId());
    
    }
    
    function errorCallback()
    
    {
    
    console.log("error");
    
    }
    
    }
    
    else if (status == "success")
    
    {
    
    Xrm.Utility.openEntityForm(Xrm.Page.data.entity.getEntityName(), Xrm.Page.data.entity.getId());
    
    }
    
    });
    
    }
    
    }

    But we don't think that "it's" the error because:
    a) We don't get that every time that we work in CRM.
    b) We have get it in other entity and only Opportunity Entity has this "script".

    So... the script that has the real "then" inside must be a websource that we can't enter to edit... What I must do?
  • Suggested answer
    Community Member Profile Picture
    on at

    Hi,

    Have you copied this script on ONLOAD event?

    Thanks

  • Suggested answer
    Temmy Wahyu Raharjo Profile Picture
    2,916 on at

    Hi, You need to create the function first. Then only assigned it to the then function:

    function successCallback()
    {
    	Xrm.Utility.openEntityForm(Xrm.Page.data.entity.getEntityName(), Xrm.Page.data.entity.getId());
    }
    
    function errorCallback()
    {
    	console.log("error");
    
    }
    Xrm.Page.data.entity.save().then(successCallback, errorCallback);
  • Suggested answer
    Kevin Grech Profile Picture
    380 on at

    If this is the actual script, check out msdn.microsoft.com/.../dn481607.aspx

    That save function in red does not return a promise. You need to use Xrm.Page.data.save()

    Edit: This Microsoft article highlights the difference https://msdn.microsoft.com/en-us/library/gg334720.aspx#BKMK_save

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans