0

currently I need some specific logic which requires using NavigationMixin onsuccess event. I spent some time and can’t find any info if it is possible at all Here is my sample of code

this[NavigationMixin.Navigate]({
        type: 'standard__objectPage',
        attributes: {
            objectApiName: this.__PrimaryObjectApi,
            actionName: 'new'
        },
        state: {
            defaultFieldValues: defaultValues
        }
    })

Will appreciate any help and additional info

1
  • Please explain, what you are trying to do and what is not working?
    – Saroj Bera
    Commented Nov 10, 2022 at 11:57

1 Answer 1

1
  1. Navigate Mixin does not have any onsuccess method

  2. But It returns a promise

  3. Something like this

  4. List item

    this[NavigationMixin.GenerateUrl]({
    
       type: 'standard__objectPage',
        attributes: {
           objectApiName: this.__PrimaryObjectApi,
           actionName: 'new'
       },
       state: {
           defaultFieldValues: defaultValues
       }}).then((url) => {
         this.recordPageUrl = url;
      });
    
  5. So you need to handle the promise using then block

  6. This would mean that the NavigateMixin was executed succesfully

  7. Else you need to append a catch block which means a error was thrown and the promise was rejected.

1
  • This answer only deals with GenerateUrl ,but the function in the question ( and the one I am also looking for an answer to) is for Navigate. That does not seem to return a promise unfortunately.
    – bpilling
    Commented Sep 25, 2023 at 12:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .