function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AK_SmithAK_Smith 

update <p> with the field value until

Hello! 
Please help me with my VF page.
i need to update <p> from the CTPHARMA__Activity__c.SF1_Status__c (text formula) until y < 6 && z && u != "Win32" returns true
 
<apex:page standardController="CTPHARMA__Activity__c" id="page" docType="html-5.0">
<style>
.good{
text-align:center;
background-color: MediumSeaGreen;
font-weight: bold;
color: white;
}
.bad{
text-align:center;
background-color: Tomato;
font-weight: bold;
color: white;
}

.ugly{
text-align:center;
background-color: LightGray;
}


</style>
  
    <apex:form styleClass="{!if(CTPHARMA__Activity__c.SF1_Status__c == 'Подтвержден территориально','good',if(CTPHARMA__Activity__c.SF1_Status__c == 'Не подтвержден территориально','bad','ugly'))} ">

<p id="text"></p>

    </apex:form>
    
    
    <script>
    myFunction();
    function myFunction(){
    var x = {!CTPHARMA__Activity__c.SF1_Status__c};
    var y = {!CTPHARMA__Activity__c.SF1_Attempts__c};
    var z = {!CTPHARMA__Activity__c.SF1_Request_geo__c};
    var u = window.navigator.platform;
    
    do{
    
    document.getElementById("text").innerHTML = x;
     } 
     while (y < 6 && z && u != "Win32")
     }
     
    </script>
 
</apex:page>

 
Best Answer chosen by AK_Smith
sfdcMonkey.comsfdcMonkey.com
hi smith, use below js code :
<script>
    myFunction();
    function myFunction(){
    var x = '{!CTPHARMA__Activity__c.SF1_Status__c}';
    var y = '{!CTPHARMA__Activity__c.SF1_Attempts__c}';
    var z = '{!CTPHARMA__Activity__c.SF1_Request_geo__c}';
    var u = window.navigator.platform;
    
    do{
    
    document.getElementById("text").innerHTML = x;
     } 
     while (y < 6 && z && u != "Win32")
     }
     
    </script>
Let us know if it helps you, and kindly mark it best answer it this answer helps you so it make proper solution for others in future 
thanks

All Answers

AK_SmithAK_Smith
User-added image
AK_SmithAK_Smith
SF1_Request_geo__c
and( 
datevalue(CTPHARMA__StartDate__c) = TODAY(), 
RecordType.Name = "1:1 Visit", 
Is_confirmed_territorially__c = False, 
SF1_Attempts__c <6)

SF1_Status__c
IF( Is_confirmed_territorially__c = true, "Подтвержден территориально", 
IF( Start_date_only__c > today(),"Этот визит не сегодня", 
IF( AND(Start_date_only__c <= today() , Is_confirmed_territorially__c = false, or(SF1_Attempts__c >=6,SF1_Attempts__c = 0)),"Не подтвержден территориально", 

IF(and( Is_confirmed_territorially__c = false, SF1_Attempts__c <6),"Попытка снятия геометки #"&text(SF1_Attempts__c)&"...", 
"Не подтвержден территориально" 

))))

 
sfdcMonkey.comsfdcMonkey.com
hi smith, use below js code :
<script>
    myFunction();
    function myFunction(){
    var x = '{!CTPHARMA__Activity__c.SF1_Status__c}';
    var y = '{!CTPHARMA__Activity__c.SF1_Attempts__c}';
    var z = '{!CTPHARMA__Activity__c.SF1_Request_geo__c}';
    var u = window.navigator.platform;
    
    do{
    
    document.getElementById("text").innerHTML = x;
     } 
     while (y < 6 && z && u != "Win32")
     }
     
    </script>
Let us know if it helps you, and kindly mark it best answer it this answer helps you so it make proper solution for others in future 
thanks
This was selected as the best answer
AK_SmithAK_Smith
Nope. The problem is with the text values
sfdcMonkey.comsfdcMonkey.com
to access your object field values in javaScript you have need to use expression inside the single quotes like below :

var x = ' {!CTPHARMA__Activity__c.SF1_Status__c} ;
 
AK_SmithAK_Smith
Thanks! I found the problem. It loops my page id frease it. 
Is it possibe to show SF1_Status__c, wait 1 second show SF1_Status__c (updated) and do until SF1_Request_geo__c = true?