Hi @Kemppaik , From what I understand, you want to get the text value from the user prompt. The code you provided is too much (it is best to provide a small example that can reproduce the problem), I only extracted a part of the code according to your needs and tested it. You need to pass prompt value to textbox value not innerText.
document.getElementById('<%= copyToTB.ClientID %>').value = copyTo;
Here is my test:
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<script>
function copy() {
var copyTo = prompt("Please enter the sales order you want to copy to", "");
if (copyTo != null) {
document.getElementById('<%= copyToTB.ClientID %>').value = copyTo;
document.getElementById('<%= copyButton.ClientID %>').click();
}
}
</script>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" AsyncPostBackTimeout="0">
<ContentTemplate>
<asp:TextBox ID="copyToTB" runat="server" CssClass="hidden-field"></asp:TextBox>
<asp:GridView ID="fileAttachmentGV" runat="server" AutoGenerateColumns="true"
CssClass="w3-table-all w3-tiny w3-table-no-border "
ShowHeader="false">
</asp:GridView>
<span tabindex="-1" class="ms-crm-CommandBar-Button ms-crm-Menu-Label" style="max-width: 200px">
<a tabindex="0" class="ms-crm-Menu-Label" onclick="copy();">
<img tabindex="-1" class="ms-crm-ImageStrip-Save_16 ms-crm-commandbar-image16by16" style="vertical-align: top" alt="Copy to a new Ticket" src="favicon.ico"></img>
<span tabindex="-1" class="ms-crm-CommandBar-Menu" style="max-width: 150px; cursor: pointer;">COPY </span>
</a>
</span>
<asp:Button ID="copyButton" Style="display: none" runat="server" Text="Copy"
OnClick="CopyButton_Click" />
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="fileAttachmentGV" />
</Triggers>
</asp:UpdatePanel>
</asp:Content>
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.