Skip to main content
Dynamics 365 Community / Forums / Finance forum / not allow to import th...
Finance forum
Answered

not allow to import the records through excel

editSubscribe (0) ShareShare
ReportReport
Posted on by 1,347
i have created the work flow on form , i have to put the condition that if work flow is in approved state the data should not be allowed to flow on forms throw excel addins how can i get this done , anyone please guide me on this .
Attachments
  • Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,458 Super User on at
    not allow to import the records through excel
    If it's working then please check " Does this answer your question" for helpful answers.
  • Verified answer
    Dineshkarlekar Profile Picture
    Dineshkarlekar 1,347 on at
    not allow to import the records through excel
    hi, 
    i have done code on validate write its working good thanks .
     
     
     
    regards,
    Dinesh
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,347 on at
    not allow to import the records through excel
    hi , 
    I have written the code on validate write please suggest the possible changes if it is wrong below is my code
      /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public boolean validateWrite()
        {
            boolean ret;
            DTDMCHeader         dTDMCHeader;
            DTDMCHeaderLines    dTDMCHeaderLines,dTDMCHeaderLinesLoc;
    
    
            dTDMCHeaderLines = this.orig();
    
            select firstonly dTDMCHeader
                where dTDMCHeader.InvoiceDate == dTDMCHeaderLines.InvoiceDate
                &&    dTDMCHeader.inventLocationId == dTDMCHeaderLines.inventLocationId;
    
            if(dTDMCHeader.DTDmcWorkFlow == DTDmcWorkFlowStatus::Draft)
            {
                select firstonly forupdate dTDMCHeaderLinesLoc
                    where dTDMCHeaderLinesLoc.InvoiceDate == dTDMCHeaderLines.InvoiceDate
                      &&  dTDMCHeaderLinesLoc.inventLocationId == dTDMCHeaderLines.inventLocationId
                      &&  dTDMCHeaderLinesLoc.InvoiceId        == dTDMCHeaderLines.InvoiceId;
                if(dTDMCHeaderLinesLoc == dTDMCHeaderLines)
                {
                    ttsbegin;
                    dTDMCHeaderLinesLoc.validateWrite();
                    ttscommit;
                }
           
            }
            else
            {
                throw error('changes cannot be made once the workflow is submitted');
            }
        
            ret = super();
        
            return ret;
        }
     
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,347 on at
    not allow to import the records through excel
       public void update()
        {
            super();
            DTDMCHeader         dTDMCHeader;
            DTDMCHeaderLines    dTDMCHeaderLines,dTDMCHeaderLinesLoc;
    
    
                 dTDMCHeaderLines = this.orig();
    
            select firstonly dTDMCHeader
                where dTDMCHeader.InvoiceDate == dTDMCHeaderLines.InvoiceDate
                &&    dTDMCHeader.inventLocationId == dTDMCHeaderLines.inventLocationId;
    
            if(dTDMCHeader.DTDmcWorkFlow == DTDmcWorkFlowStatus::Draft)
            {
                ttsbegin;
               select firstonly forupdate dTDMCHeaderLinesLoc
                    where dTDMCHeaderLinesLoc.InvoiceDate == dTDMCHeaderLines.InvoiceDate
                      &&  dTDMCHeaderLinesLoc.inventLocationId == dTDMCHeaderLines.inventLocationId
                      &&  dTDMCHeaderLinesLoc.InvoiceId        == dTDMCHeaderLines.InvoiceId;
                ttscommit;
            }
        }
     
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,347 on at
    not allow to import the records through excel
    hi , 
    thanks for reply 
    i have debugged the purchase order header v2 entity so when i tried to update the email id in existing purchase order the update code of purchtable get hits and and the updateEntityDataSource of the entity gets hit do i have to code on update and validate write both.
    below is my update code .
    please suggest me what changes i have to make in my update code as i want to update the whole selected record. i am not getting how to  update whole record . after comparing with orig() .
    when i download excel the of the lines table the excel is editable , so if i have to create whole new line through excel then i should use validate write and if i want to update the line should i use validatewrite.
     
    below is my code to update record plz suggest any changes i need to do .
  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,458 Super User on at
    not allow to import the records through excel
    As Martin suggested did you take care of those scenarios as well?
     
    To answer your question, you can write a validation in validatewrite() of that table checking the orig() of the record and if it is approved then throw error in validatewrite. This way you can stop approved item from getting edited from external means.
  • Martin Dráb Profile Picture
    Martin Dráb 222,978 Super User on at
    not allow to import the records through excel
    Hmm, saying that the data can't be edited in Excel but can be by all other means (forms, data import, OData, Power Apps...) sound very strange. What is the business problem that you've decided to solve by this design?

Helpful resources

Quick Links

New Blog Features Released!

Check out the new community blog features for viewers and authors…

Demystifying Copilot with Sundar Raghavan

Sundar explains how Copilot for Service is meant to function separately...

Business Process Guidance Badges and New…

The Microsoft Success by Design is the framework for implementing Dynamics 365…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,266 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 222,978 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,140

Featured topics

Product updates

Dynamics 365 release plans