Answered by:
Return status of quote via javascript

Question
-
I need to retrieve the quote status, how can I do this with javascript?
regards,
Matt
Friday, September 20, 2013 4:07 PM
Answers
-
Make sure you add the statecode attribute on the form. This is probably errors because it cannot find the field on the form.
HTH
Sam
Dynamics CRM MVP | Inogic | http://inogic.blogspot.com| news at inogic dot com
If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"
- Proposed as answer by Sam - Inogic Monday, September 23, 2013 8:45 AM
- Marked as answer by Matt_Hirst_UK Monday, September 23, 2013 10:37 AM
Monday, September 23, 2013 8:45 AM
All replies
-
Hi Matt,
Do you want this JavaScript on quote form itself? Use below code. Please make sure that fields are on the form.
Xrm.Page.getAttribute('statecode').getValue()
Xrm.Page.getAttribute('statuscode').getValue()
If you don't want to add these fields on form then you can use Odata Or Soap to Retrieve Quote.
http://mileyja.blogspot.in/2011/04/how-to-use-retrieve-messages-in-jscript.html
http://mileyja.blogspot.in/2011/03/crm-2011-retrievemultiple-calls-in.html
Hope this helps!
Thanks!
- Edited by Kalim Khan Friday, September 20, 2013 5:20 PM
- Proposed as answer by JLattimerMVP, Moderator Friday, September 20, 2013 6:01 PM
Friday, September 20, 2013 5:20 PM -
If I use:
Xrm.Page.getAttribute('statecode').getValue()
I get an error message and this is what is sent to microsoft:
Microsoft Dynamics CRM Error Report Contents <CrmScriptErrorReport> <ReportVersion>1.0</ReportVersion> <ScriptErrorDetails> <Message>Unable to get value of the property 'getValue': object is null or undefined</Message> <Line>82</Line> <URL>/main.aspx?etc=1084&extraqs=%3f_gridType%3d1084%26etc%3d1084%26id%3d%257bD031D987-3216-E311-8ECF-02BF0A86F1E1%257d%26pagemode%3diframe%26preloadcache%3d1379925092115%26rskey%3d925855683&pagetype=entityrecord</URL> <PageURL>/main.aspx?etc=1084&extraqs=%3f_gridType%3d1084%26etc%3d1084%26id%3d%257bD031D987-3216-E311-8ECF-02BF0A86F1E1%257d%26pagemode%3diframe%26preloadcache%3d1379925092115%26rskey%3d925855683&pagetype=entityrecord</PageURL> <Function></Function> <CallStack> </CallStack> </ScriptErrorDetails> <ClientInformation> <BrowserUserAgent>Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.3)</BrowserUserAgent> <BrowserLanguage>en-us</BrowserLanguage> <SystemLanguage>en-us</SystemLanguage> <UserLanguage>en-gb</UserLanguage> <ScreenResolution>1280x1024</ScreenResolution> <ClientName>Web</ClientName> <ClientTime>2013-09-23T09:31:35</ClientTime> </ClientInformation> <ServerInformation> <OrgLanguage>1033</OrgLanguage> <OrgCulture>2057</OrgCulture> <UserLanguage>1033</UserLanguage> <UserCulture>2057</UserCulture> <OrgID>{243A0FF8-F595-E211-96EA-02BF0A86F1E1}</OrgID> <UserID>{82BC61EF-740C-E211-A4D0-02BF0A86F1E1}</UserID> <CRMVersion>5.0.9690.2865</CRMVersion> </ServerInformation> </CrmScriptErrorReport>
This is on any quote whether draft or active.
regards,
Matt
Monday, September 23, 2013 8:33 AM -
Make sure you add the statecode attribute on the form. This is probably errors because it cannot find the field on the form.
HTH
Sam
Dynamics CRM MVP | Inogic | http://inogic.blogspot.com| news at inogic dot com
If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"
- Proposed as answer by Sam - Inogic Monday, September 23, 2013 8:45 AM
- Marked as answer by Matt_Hirst_UK Monday, September 23, 2013 10:37 AM
Monday, September 23, 2013 8:45 AM -
It is on the form but it is in the footer.
If I add it to the form it works ok but remove it and it fails, so can it be referenced in the footer of the form or not?
Matt
Monday, September 23, 2013 9:09 AM -
Hi Matt,
As I have mentioned the field should be available on form not footer. The footer elements can be read through unsupported way. Please avoid unsupported way.
var footer = document.getElementById('crmFormFooter');
var status = footer.document.getElementById("footer_statecode_d");
var text= status.innerText;If you don't want to put the fields on form then you can Retrieve the Quote using Odata or Soap as I have suggested earlier.
http://mileyja.blogspot.in/2011/04/how-to-use-retrieve-messages-in-jscript.html
http://mileyja.blogspot.in/2011/03/crm-2011-retrievemultiple-calls-in.html
Hope this helps!
Thanks!
If this post helps you, please click "Mark As Answer" on the post and "Vote as Helpful"
Monday, September 23, 2013 9:17 AM -
I ended up putting the field on the form and hiding the field as the other links are beyond me at the moment and I also didn't want to use the unsupported code.
regards,
Matt
Monday, September 23, 2013 9:53 AM -
Hi Matt,
If replies helped you, would you please close this by clicking "Mark As Answer" on the post and "Vote as Helpful"? It may help others.
Thanks!
Monday, September 23, 2013 9:57 AM